当前位置: 首页>>代码示例>>Java>>正文


Java CompositeDisposable.dispose方法代码示例

本文整理汇总了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());
    }
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:23,代码来源:DisposableAttachFlowableTest.java

示例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());
}
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:21,代码来源:DisposableAttachSingleTest.java

示例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());
    }
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:22,代码来源:DisposableAttachMaybeTest.java

示例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());
}
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:20,代码来源:DisposableAttachObservableTest.java

示例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());
    }
 
开发者ID:cp949,项目名称:DisposableAttach,代码行数:21,代码来源:DisposableAttachCompletableTest.java

示例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);
    }
}
 
开发者ID:mahmed8003,项目名称:RxLifecycle,代码行数:9,代码来源:RxFragment.java

示例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);
    }
}
 
开发者ID:mahmed8003,项目名称:RxLifecycle,代码行数:9,代码来源:RxActivity.java

示例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());
    }
}
 
开发者ID:MFlisar,项目名称:RxBus2,代码行数:10,代码来源:RxDisposableManager.java

示例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);
        }
    }
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:15,代码来源:RxBus.java


注:本文中的io.reactivex.disposables.CompositeDisposable.dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。