Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions autodispose/src/main/java/com/uber/autodispose/ScopeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
*/
public interface ScopeProvider {

/**
* A new provider that is "unbound", e.g. will emit a completion event to signal that the
* scope is unbound.
*/
ScopeProvider UNBOUND = new ScopeProvider() {
@Override public Maybe<?> requestScope() {
return Maybe.empty();
}
};

/**
* @return a Maybe that, upon emission, will trigger disposal.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public static TestScopeProvider create(Maybe<?> delegate) {
* scope is unbound.
*
* @return the created TestScopeProvider
* @deprecated in favor of {@link ScopeProvider#UNBOUND}. This method will be removed in 1.0.
*/
public static TestScopeProvider unbound() {
@Deprecated public static TestScopeProvider unbound() {
return create(Maybe.empty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.reactivex.CompletableEmitter;
import io.reactivex.CompletableObserver;
import io.reactivex.CompletableOnSubscribe;
import io.reactivex.Maybe;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Cancellable;
import io.reactivex.functions.Consumer;
Expand Down Expand Up @@ -311,7 +310,7 @@ public CompletableObserver apply(Completable source, CompletableObserver observe
}
});
Completable.complete()
.to(AutoDispose.with(Maybe.never())
.to(AutoDispose.with(ScopeProvider.UNBOUND)
.forCompletable())
.subscribe();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AutoDisposeMaybeObserverTest {

@Test public void autoDispose_withSuperClassGenerics_compilesFine() {
Maybe.just(new BClass())
.to(AutoDispose.with(Maybe.never()).<AClass>forMaybe())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<AClass>forMaybe())
.subscribe(new Consumer<AClass>() {
@Override public void accept(AClass aClass) throws Exception {

Expand All @@ -84,7 +84,7 @@ public class AutoDisposeMaybeObserverTest {

@Test public void autoDispose_noGenericsOnEmpty_isFine() {
Maybe.just(new BClass())
.to(AutoDispose.with(Maybe.never())
.to(AutoDispose.with(ScopeProvider.UNBOUND)
.forMaybe())
.subscribe();
}
Expand Down Expand Up @@ -343,7 +343,7 @@ public class AutoDisposeMaybeObserverTest {
}
});
Maybe.just(1)
.to(AutoDispose.with(Maybe.never()).<Integer>forMaybe())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<Integer>forMaybe())
.subscribe();

assertThat(atomicAutoDisposingObserver.get()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.uber.autodispose.observers.AutoDisposingObserver;
import com.uber.autodispose.test.RecordingObserver;
import io.reactivex.Maybe;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
Expand Down Expand Up @@ -77,7 +76,7 @@ public class AutoDisposeObserverTest {

@Test public void autoDispose_withSuperClassGenerics_compilesFine() {
Observable.just(new BClass())
.to(AutoDispose.with(Maybe.never()).<AClass>forObservable())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<AClass>forObservable())
.subscribe(new Consumer<AClass>() {
@Override public void accept(AClass aClass) throws Exception {

Expand All @@ -87,7 +86,7 @@ public class AutoDisposeObserverTest {

@Test public void autoDispose_noGenericsOnEmpty_isFine() {
Observable.just(new BClass())
.to(AutoDispose.with(Maybe.never())
.to(AutoDispose.with(ScopeProvider.UNBOUND)
.forObservable())
.subscribe();
}
Expand Down Expand Up @@ -278,7 +277,7 @@ public class AutoDisposeObserverTest {
}
});
Observable.just(1)
.to(AutoDispose.with(Maybe.never()).<Integer>forObservable())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<Integer>forObservable())
.subscribe();

assertThat(atomicAutoDisposingObserver.get()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.uber.autodispose.observers.AutoDisposingSingleObserver;
import com.uber.autodispose.test.RecordingObserver;
import io.reactivex.Maybe;
import io.reactivex.Single;
import io.reactivex.SingleEmitter;
import io.reactivex.SingleObserver;
Expand Down Expand Up @@ -76,7 +75,7 @@ public class AutoDisposeSingleObserverTest {

@Test public void autoDispose_withSuperClassGenerics_compilesFine() {
Single.just(new BClass())
.to(AutoDispose.with(Maybe.never()).<AClass>forSingle())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<AClass>forSingle())
.subscribe(new Consumer<AClass>() {
@Override public void accept(AClass aClass) throws Exception {

Expand All @@ -86,7 +85,7 @@ public class AutoDisposeSingleObserverTest {

@Test public void autoDispose_noGenericsOnEmpty_isFine() {
Single.just(new BClass())
.to(AutoDispose.with(Maybe.never())
.to(AutoDispose.with(ScopeProvider.UNBOUND)
.forSingle())
.subscribe();
}
Expand Down Expand Up @@ -314,7 +313,7 @@ public class AutoDisposeSingleObserverTest {
}
});
Single.just(1)
.to(AutoDispose.with(Maybe.never()).<Integer>forSingle())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<Integer>forSingle())
.subscribe();

assertThat(atomicAutoDisposingObserver.get()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.reactivex.Flowable;
import io.reactivex.FlowableEmitter;
import io.reactivex.FlowableOnSubscribe;
import io.reactivex.Maybe;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Cancellable;
Expand Down Expand Up @@ -72,7 +71,7 @@ public class AutoDisposeSubscriberTest {

@Test public void autoDispose_withSuperClassGenerics_compilesFine() {
Flowable.just(new BClass())
.to(AutoDispose.with(Maybe.never()).<AClass>forFlowable())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<AClass>forFlowable())
.subscribe(new Consumer<AClass>() {
@Override public void accept(AClass aClass) throws Exception {

Expand All @@ -82,7 +81,7 @@ public class AutoDisposeSubscriberTest {

@Test public void autoDispose_noGenericsOnEmpty_isFine() {
Flowable.just(new BClass())
.to(AutoDispose.with(Maybe.never())
.to(AutoDispose.with(ScopeProvider.UNBOUND)
.forFlowable())
.subscribe();
}
Expand Down Expand Up @@ -289,7 +288,7 @@ public class AutoDisposeSubscriberTest {
}
});
Flowable.just(1)
.to(AutoDispose.with(Maybe.never()).<Integer>forFlowable())
.to(AutoDispose.with(ScopeProvider.UNBOUND).<Integer>forFlowable())
.subscribe();

assertThat(atomicAutoDisposingSubscriber.get()).isNotNull();
Expand Down