本文整理汇总了Java中io.reactivex.disposables.CompositeDisposable.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeDisposable.dispose方法的具体用法?Java CompositeDisposable.dispose怎么用?Java CompositeDisposable.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.disposables.CompositeDisposable
的用法示例。
在下文中一共展示了CompositeDisposable.dispose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Test public void test() {
PublishProcessor<String> subject = PublishProcessor.create();
Flowable<String> source = subject.hide();
TestSubscriber testSubscriber = new TestSubscriber();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = source
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testSubscriber);
subject.onNext("Foo");
testSubscriber.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testSubscriber.isDisposed());
}
示例2: test
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Test public void test() {
SingleSubject<String> subject = SingleSubject.create();
Single<String> singleSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = singleSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例3: test
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Test public void test() {
MaybeSubject<String> subject = MaybeSubject.create();
Maybe<String> maybeSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = maybeSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例4: test
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Test public void test() {
PublishSubject<String> subject = PublishSubject.create();
Observable<String> observerable = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = observerable
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onNext("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例5: test
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Test public void test() {
CompletableSubject subject = CompletableSubject.create();
Completable source = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = source
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例6: disposeAndRemove
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private void disposeAndRemove(FragmentEvent event) {
if (disposables.containsKey(event)) {
CompositeDisposable disposable = disposables.get(event);
disposable.dispose();
disposable.clear();
disposables.remove(event);
}
}
示例7: disposeAndRemove
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private void disposeAndRemove(ActivityEvent event) {
if (disposables.containsKey(event)) {
CompositeDisposable disposable = disposables.get(event);
disposable.dispose();
disposable.clear();
disposables.remove(event);
}
}
示例8: doUnsubscribe
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private void doUnsubscribe(Object boundObject)
{
CompositeDisposable disposables = mDisposables.get(boundObject.getClass());
if (disposables != null)
{
disposables.dispose();
mDisposables.remove(boundObject.getClass());
}
}
示例9: main
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
public static void main(String[] args) {
// TODO Auto-generated method stub
CompositeDisposable disposable = new CompositeDisposable();
disposable.add(Flowable.rangeLong(10, 5).subscribe(System.out::println));
disposable.add(Flowable.rangeLong(1, 5).subscribe(item -> System.out.println("two" + item)));
disposable.add(Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
// TODO Auto-generated method stub
try {
String[] monthArray = { "Jan", "Feb", "Mar", "Apl", "May", "Jun", "July", "Aug", "Sept", "Oct",
"Nov", "Dec" };
List<String> months = Arrays.asList(monthArray);
for (String month : months) {
emitter.onNext(month);
}
emitter.onComplete();
} catch (Exception e) {
// TODO: handle exception
emitter.onError(e);
}
}
}).subscribe(s -> System.out.println(s)));
disposable.dispose();
}
开发者ID:PacktPublishing,项目名称:Reactive-Programming-With-Java-9,代码行数:34,代码来源:DemoCompositeDisposable.java
示例10: unRegister
import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
/**
* 解除订阅者
* @param subscriber 订阅者
*/
public void unRegister(Object subscriber) {
CompositeDisposable compositeDisposable;
if(subscriber != null){
compositeDisposable = subscriptions.get(subscriber);
if(compositeDisposable != null){
compositeDisposable.dispose();
subscriptions.remove(subscriber);
}
}
}