Search in sources :

Example 1 with Subject

use of io.reactivex.subjects.Subject in project mosby by sockeqwe.

the class MviBasePresenter method bindIntentActually.

@MainThread
private <I> Observable<I> bindIntentActually(@NonNull V view, @NonNull IntentRelayBinderPair<?> relayBinderPair) {
    if (view == null) {
        throw new NullPointerException("View is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
    }
    if (relayBinderPair == null) {
        throw new NullPointerException("IntentRelayBinderPair is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
    }
    Subject<I> intentRelay = (Subject<I>) relayBinderPair.intentRelaySubject;
    if (intentRelay == null) {
        throw new NullPointerException("IntentRelay from binderPair is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
    }
    ViewIntentBinder<V, I> intentBinder = (ViewIntentBinder<V, I>) relayBinderPair.intentBinder;
    if (intentBinder == null) {
        throw new NullPointerException(ViewIntentBinder.class.getSimpleName() + " is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues");
    }
    Observable<I> intent = intentBinder.bind(view);
    if (intent == null) {
        throw new NullPointerException("Intent Observable returned from Binder " + intentBinder + " is null");
    }
    if (intentDisposables == null) {
        intentDisposables = new CompositeDisposable();
    }
    intentDisposables.add(intent.subscribeWith(new DisposableIntentObserver<I>(intentRelay)));
    return intentRelay;
}
Also used : Subject(io.reactivex.subjects.Subject) BehaviorSubject(io.reactivex.subjects.BehaviorSubject) ReplaySubject(io.reactivex.subjects.ReplaySubject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) MainThread(android.support.annotation.MainThread)

Aggregations

MainThread (android.support.annotation.MainThread)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 BehaviorSubject (io.reactivex.subjects.BehaviorSubject)1 ReplaySubject (io.reactivex.subjects.ReplaySubject)1 Subject (io.reactivex.subjects.Subject)1