-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using LifecycleObservable #127
Comments
Consider There is also a It's part of the framework while we figure out where it should go. Framework is more experimental things. |
The two sort of work in tandem and perhaps should be combined:
Ideally we'd fix the underlying problem that See more info here: #95 (comment) |
@amitai-hoze Yep, listen to @dlew as he wrote You should bind the observable itself upon creation. |
@ersin-ertan, You also need to add the compile 'io.reactivex:rxandroid-framework:0.24.0' |
@dlew, the documentation of Does this mean I don't have to use public class SomeView extends LinearLayout {
private Button someButton;
@Override
protected void onFinishInflate() {
super.onFinishInflate();
someButton = (Button) findViewById(R.id.some_button);
Observable<OnClickEvent> someButtonClicks =
ViewObservable.bindView(this,ViewObservable.clicks(sendPhoneButton));
someButtonClicks.subscribe(onClickEvent -> {/*do something*/});
}
} |
@dlew, a few more questions. Also, you said that |
OK, I think I figured it out. Where in an observable chain to call the bind methods Which kind of observable needs which binding method UI events Observables Those don't need to use Background events Observables e.g. a network request, a broadcast receiver etc. These should use |
Sorry for the delayed response, been out of town. Taking things in order...
"what kind of observable continues emitting items after it is unsubscribed from" - It's an unintended side effect of the |
Thanks.
|
Also, Views have |
OK, thanks a lot. |
I've never had it happen myself, only heard of it happening from @mttkay. |
I believe we ran into this with OperatorCache, because these operators
|
Execute me . Is there any sample MVVM-like project regarding to this discussion ? There's another sample project rx-android-architecture by tehmou , not using LifecycleObservable / AppObservable or any ViewObservable.bindView , instead he uses WeakReference to solve the problem. Is there any drawback regarding to that solution ? ( I mean the MVVM design ) Thanks. |
LifecycleObservable has been removed for future releases as part of #172. While it might come back in some form, you're much better off either emitting specific events for the lifecycle or explicitly unsubscribing in the callback. |
Hi, it seems that using
LifecycleObservable
and binding it to an activity or fragment, obviates the need forAppObservable
, am I correct, or do I need to use both in conjunction?My guess is that
LifecycleObservable
includes the features ofAppObservable
, but since it's a part ofrxandroid-framework
and not the core,AppObservable
is not deprecated or something like that.Also, can I use
LifecycleObservable.bindActivityLifecycle
whenever I want? (i.e. after different observable operators etc.)The text was updated successfully, but these errors were encountered: