Skip to content
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

Merged
merged 3 commits into from
Nov 4, 2016
Merged

Upgrade to RxJava 2 #167

merged 3 commits into from
Nov 4, 2016

Conversation

dlew
Copy link
Contributor

@dlew dlew commented Nov 4, 2016

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).

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).
@dlew dlew changed the base branch from master to 2.x November 4, 2016 13:51
= this.compose(RxLifecycleAndroid.bindView<T>(view))
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #163 and #164

* {@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
Copy link
Contributor

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
Copy link
Contributor

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,
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

@dlew dlew merged commit 28ec8e8 into 2.x Nov 4, 2016
@dlew dlew deleted the dlew/rxjava2 branch November 4, 2016 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants