Search in sources :

Example 76 with CompositeDisposable

use of io.reactivex.disposables.CompositeDisposable in project RxJava-Android-Samples by kaushikgopal.

the class RxBusDemo_Bottom2Fragment method onStart.

@Override
public void onStart() {
    super.onStart();
    _disposables = new CompositeDisposable();
    Flowable<Object> tapEventEmitter = _rxBus.asFlowable().share();
    _disposables.add(tapEventEmitter.subscribe(event -> {
        if (event instanceof RxBusDemoFragment.TapEvent) {
            _showTapText();
        }
    }));
    Flowable<Object> debouncedEmitter = tapEventEmitter.debounce(1, TimeUnit.SECONDS);
    Flowable<List<Object>> debouncedBufferEmitter = tapEventEmitter.buffer(debouncedEmitter);
    _disposables.add(debouncedBufferEmitter.observeOn(AndroidSchedulers.mainThread()).subscribe(taps -> {
        _showTapCount(taps.size());
    }));
}
Also used : Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) LayoutInflater(android.view.LayoutInflater) MainActivity(com.morihacky.android.rxjava.MainActivity) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ViewGroup(android.view.ViewGroup) BindView(butterknife.BindView) R(com.morihacky.android.rxjava.R) TimeUnit(java.util.concurrent.TimeUnit) BaseFragment(com.morihacky.android.rxjava.fragments.BaseFragment) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) List(java.util.List) TextView(android.widget.TextView) Flowable(io.reactivex.Flowable) View(android.view.View) ViewCompat(android.support.v4.view.ViewCompat) Nullable(android.support.annotation.Nullable) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Example 77 with CompositeDisposable

use of io.reactivex.disposables.CompositeDisposable in project BaseProject by fly803.

the class RxBus method unregister.

public void unregister(@NonNull Object observer) {
    ObjectHelper.requireNonNull(observer, "Observer to unregister must not be null.");
    CompositeDisposable composite = OBSERVERS.get(observer.getClass());
    ObjectHelper.requireNonNull(composite, "Missing observer, it was registered?");
    composite.dispose();
    OBSERVERS.remove(observer.getClass());
    Set<CustomSubscriber<?>> subscribers = SUBSCRIBERS.get(observer.getClass());
    if (subscribers != null) {
        subscribers.clear();
        SUBSCRIBERS.remove(observer.getClass());
    }
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Example 78 with CompositeDisposable

use of io.reactivex.disposables.CompositeDisposable in project seven_develop by seven123456.

the class RxLifeManager method setCompositeDisposableOnStop.

public void setCompositeDisposableOnStop(@NonNull Disposable s) {
    if (compositeDisposableOnStop != null) {
        compositeDisposableOnStop.add(s);
    } else {
        compositeDisposableOnStop = new CompositeDisposable();
        compositeDisposableOnStop.add(s);
    }
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable)

Aggregations

CompositeDisposable (io.reactivex.disposables.CompositeDisposable)78 Nullable (android.support.annotation.Nullable)15 Test (org.junit.Test)11 Bundle (android.os.Bundle)10 View (android.view.View)10 Consumer (io.reactivex.functions.Consumer)10 TimeUnit (java.util.concurrent.TimeUnit)10 Flowable (io.reactivex.Flowable)9 NonNull (android.support.annotation.NonNull)8 TextUtils (android.text.TextUtils)7 ViewGroup (android.view.ViewGroup)7 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)7 TextView (android.widget.TextView)6 BindView (butterknife.BindView)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Intent (android.content.Intent)5 LayoutInflater (android.view.LayoutInflater)5 Task (bolts.Task)5 TaskCompletionSource (bolts.TaskCompletionSource)5