diff --git a/autodispose/src/main/java/com/uber/autodispose/ScopeProvider.java b/autodispose/src/main/java/com/uber/autodispose/ScopeProvider.java index 6277902e0..3cee119f0 100755 --- a/autodispose/src/main/java/com/uber/autodispose/ScopeProvider.java +++ b/autodispose/src/main/java/com/uber/autodispose/ScopeProvider.java @@ -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. */ diff --git a/autodispose/src/main/java/com/uber/autodispose/TestScopeProvider.java b/autodispose/src/main/java/com/uber/autodispose/TestScopeProvider.java index 4da06bca1..f7b098d9c 100644 --- a/autodispose/src/main/java/com/uber/autodispose/TestScopeProvider.java +++ b/autodispose/src/main/java/com/uber/autodispose/TestScopeProvider.java @@ -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()); } diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java index 91e2017ac..89b8e1342 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeCompletableObserverTest.java @@ -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; @@ -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(); diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java index 68d79798d..cbe0e2c10 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeMaybeObserverTest.java @@ -74,7 +74,7 @@ public class AutoDisposeMaybeObserverTest { @Test public void autoDispose_withSuperClassGenerics_compilesFine() { Maybe.just(new BClass()) - .to(AutoDispose.with(Maybe.never()).forMaybe()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forMaybe()) .subscribe(new Consumer() { @Override public void accept(AClass aClass) throws Exception { @@ -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(); } @@ -343,7 +343,7 @@ public class AutoDisposeMaybeObserverTest { } }); Maybe.just(1) - .to(AutoDispose.with(Maybe.never()).forMaybe()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forMaybe()) .subscribe(); assertThat(atomicAutoDisposingObserver.get()).isNotNull(); diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java index 719b957ef..4b4c81022 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeObserverTest.java @@ -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; @@ -77,7 +76,7 @@ public class AutoDisposeObserverTest { @Test public void autoDispose_withSuperClassGenerics_compilesFine() { Observable.just(new BClass()) - .to(AutoDispose.with(Maybe.never()).forObservable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forObservable()) .subscribe(new Consumer() { @Override public void accept(AClass aClass) throws Exception { @@ -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(); } @@ -278,7 +277,7 @@ public class AutoDisposeObserverTest { } }); Observable.just(1) - .to(AutoDispose.with(Maybe.never()).forObservable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forObservable()) .subscribe(); assertThat(atomicAutoDisposingObserver.get()).isNotNull(); diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java index c41ff6e17..ea6260e06 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSingleObserverTest.java @@ -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; @@ -76,7 +75,7 @@ public class AutoDisposeSingleObserverTest { @Test public void autoDispose_withSuperClassGenerics_compilesFine() { Single.just(new BClass()) - .to(AutoDispose.with(Maybe.never()).forSingle()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forSingle()) .subscribe(new Consumer() { @Override public void accept(AClass aClass) throws Exception { @@ -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(); } @@ -314,7 +313,7 @@ public class AutoDisposeSingleObserverTest { } }); Single.just(1) - .to(AutoDispose.with(Maybe.never()).forSingle()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forSingle()) .subscribe(); assertThat(atomicAutoDisposingObserver.get()).isNotNull(); diff --git a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java index 5cd98f629..23d3f7669 100755 --- a/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java +++ b/autodispose/src/test/java/com/uber/autodispose/AutoDisposeSubscriberTest.java @@ -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; @@ -72,7 +71,7 @@ public class AutoDisposeSubscriberTest { @Test public void autoDispose_withSuperClassGenerics_compilesFine() { Flowable.just(new BClass()) - .to(AutoDispose.with(Maybe.never()).forFlowable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forFlowable()) .subscribe(new Consumer() { @Override public void accept(AClass aClass) throws Exception { @@ -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(); } @@ -289,7 +288,7 @@ public class AutoDisposeSubscriberTest { } }); Flowable.just(1) - .to(AutoDispose.with(Maybe.never()).forFlowable()) + .to(AutoDispose.with(ScopeProvider.UNBOUND).forFlowable()) .subscribe(); assertThat(atomicAutoDisposingSubscriber.get()).isNotNull();