I'am fairly new to RxJava and try to build up the Model View Intent Pattern in Android. In my View (Activity) i create a PublishProcessor as follows:
private PublishProcessor<MviResultIntent> mPublishProcessor;
mPublishProcessor = PublishProcessor.create();
After the creation I'am calling a method of my presenter with the Processor as a Parameter:
mResultPresenter.bindIntents(mPublishProcessor);
What happens inside the called method:
Disposable processIntents = mPublishProcessor
.subscribeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSubscriber<MviResultIntent>() {
@Override
public void onNext(MviResultIntent mviResultIntent) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
//may be ignored
}
});
mCompositeDisposable.add(processIntents);
and in my View Class i call afterwards:
mPublishProcessor.onNext(new MviResultIntent.ProductsIntent());
The PublishProcessor inside my Presenter does not get the onNext Event I'am trying to trigger. Am i missing something? I dont receive onComplete or onError neither.
Any help is appreciated! If you need any further Information feel free to ask. Thanks in advance for your help!
mPublishProcessor.hasSubscribers()
beforeonNext
to verify there are actually subscriber(s) listening the time. – akarnokdsubscribeWith
way before the event is fired. – akarnokd