-
Notifications
You must be signed in to change notification settings - Fork 638
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
Upgrade to RxJava 2 #167
Upgrade to RxJava 2 #167
Conversation
The goal here is just to start the big transition, I'm sure there are lots of little polishes/improvements we can do once this is in. Some of the bigger changes: - Removed dependency on RxBinding since there is no RxJava 2-based RxBinding yet. Implementing our own ViewDetachesOnSubscribe was not that bad. - Rolled all Transformers into a single LifecycleTransformer, now that we can do so (due to composition-friendly interfaces).
= this.compose(RxLifecycleAndroid.bindView<T>(view)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing extension methods for Maybe + Flowable. So far I also didn't see that support was added for those. This is just meant as a reminder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* {@code source.compose(RxLifecycle.bind(lifecycle)).subscribe()} | ||
* <p> | ||
* This helper automatically determines (based on the lifecycle sequence itself) when the source | ||
* should stop emitting items. Note that for this method, it assumes <em>any</em> event | ||
* emitted by the given lifecycle indicates that the lifecycle is over. | ||
* | ||
* @param lifecycle the lifecycle sequence | ||
* @return a reusable {@link Observable.Transformer} that unsubscribes the source whenever the lifecycle emits | ||
* @return a reusable {@link ObservableTransformer} that unsubscribes the source whenever the lifecycle emits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it returns a LifecycleTransformer
* {@code source.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.STOP)).subscribe()} | ||
* | ||
* @param lifecycle the lifecycle sequence | ||
* @param event the event which should conclude notifications from the source | ||
* @return a reusable {@link Observable.Transformer} that unsubscribes the source at the specified event | ||
* @return a reusable {@link ObservableTransformer} that unsubscribes the source at the specified event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it returns LifecycleTransformer
that implements ObservableTransformer
plus the one for Single + Completable
@@ -83,16 +84,16 @@ private RxLifecycle() { | |||
* | |||
* @param lifecycle the lifecycle sequence | |||
* @param correspondingEvents a function which tells the source when to unsubscribe | |||
* @return a reusable {@link Observable.Transformer} that unsubscribes the source during the Fragment lifecycle | |||
* @return a reusable {@link ObservableTransformer} that unsubscribes the source during the Fragment lifecycle | |||
*/ | |||
@Nonnull | |||
@CheckReturnValue | |||
public static <T, R> LifecycleTransformer<T> bind(@Nonnull Observable<R> lifecycle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
|
||
@Override | ||
public CompletableSource apply(Completable upstream) { | ||
return Completable.amb( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider using Completable.ambArray here
|
||
@Override | ||
public CompletableSource apply(Completable upstream) { | ||
return Completable.amb( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider using Completable.ambArray here
|
||
@Override | ||
public CompletableSource apply(Completable upstream) { | ||
return Completable.amb( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider using Completable.ambArray here
.compose(new UntilLifecycleTransformer<String, String>(lifecycle)) | ||
.test(); | ||
|
||
testObserver.assertNoValues(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
Now that we have just one omni-transformer
The goal here is just to start the big transition, I'm sure there are
lots of little polishes/improvements we can do once this is in.
Some of the bigger changes:
Removed dependency on RxBinding since there is no RxJava 2-based
RxBinding yet. Implementing our own ViewDetachesOnSubscribe was
not that bad.
Rolled all Transformers into a single LifecycleTransformer, now that
we can do so (due to composition-friendly interfaces).