zhihu / rxlifecycle Goto Github PK
View Code? Open in Web Editor NEWBind observables to the lifecycle of Activity or Fragment in a non-invasive way.
Bind observables to the lifecycle of Activity or Fragment in a non-invasive way.
when binding on Activity/Fragment onCreate() , Rxlifecycle would add an bindingFragment, look like this:
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "" + "ActionBarActivity onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jnitest);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment(), "myfragment")
.commit();
}
Log.d(TAG, "Fragment:"+getSupportFragmentManager().findFragmentById(R.id.container));
findFragmentById will return null.
if we bind lifeCycle during onCreate() more than once, which is very common to do such as load a lot of data, it would attach more than one BindingFragment !
and it seems to be wrong.
I read the sample, it only support android.app.Fragment?
If i use android.support.v4.app.Fragment. What should I do?
I just read the code, it's an interesting way to get notified of activity lifecycle event via a headless fragment, thanks!
I think you can mention this idea in README.
I have problem with release build of application (proguard enabled). All observables not emitting any events when is added bind to fragment. Do You have any idea how to configure proguard for this lib?
Example code:
public class TestFragment extends android.support.v4.app.Fragment{
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
new RxDao()
.fetchAll()
.compose(RxLifecycleCompact.bind(this).withObservable())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::addItems);
}
}
The method bind needs android.app.Fragment,thank you
什么时候支持rxjava3
onComplete
still be signalled after Activity's onDestroy
. That means we cannot do some operations(such as dismiss dialog) in onComplete
after the activity has been destroyed.
So any suggestions for that situation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.