如何等待Subject.onNext(o)?

时间:2017-01-07 17:09:29

标签: java rx-java

实施public class RxBus<E> { private final Subject<E, E> subject = new SerializedSubject<>(PublishSubject.<E>create()); public void post(E o) { subject.onNext(o); } public Observable<E> observe() { return subject; } }

dataEventsBus.observe()
        .compose(RxP.ofTypes(
                DataEvent.Participant.Edit.class,
                DataEvent.Participant.Approved.class
        ))
        .flatMap(dataEvent -> updateParticipantCache())
        .subscribe();

典型用户:

public void createTransactionsByAllocation(..., Subscriber<List<Transaction>> subscriber) {
    projectSession.getProject()
            .flatMap(project -> ...)
            .doOnCompleted(() -> dataEventsBus.post(new DataEvent.Participant.NewPayment()))
            .subscribeOn(ioScheduler)
            .observeOn(mainThreadScheduler) // I want this Observabel to be compleated only
            .subscribe(subscriber); // when all bus's subscriber will be completed
}

典型海报:

.flatMap(dataEventsBus.post(new DataEvent.Participant.NewPayment()))

我能以某种方式等待所有巴士的订户吗?

看起来我必须将发布活动作为链条的一部分。像v2017-01-07T16:59:37+00:00一样。我该如何实施呢?

0 个答案:

没有答案