Skip to content

Instantly share code, notes, and snippets.

@josuf107
Last active March 26, 2019 21:53
Show Gist options
  • Save josuf107/10a20de85490593e232cd985ca07e699 to your computer and use it in GitHub Desktop.
Save josuf107/10a20de85490593e232cd985ca07e699 to your computer and use it in GitHub Desktop.
private final Subject<CurrentJob, CurrentJob> jobSubject = PublishSubject.create();
private final Observable<CurrentJob> jobObservable = jobSubject
.flatMap(job -> api call etc...)
.doOnNext(job -> job.toReadEvents().forEach(this::processJobReadEvent));
...
startDocument() {
jobObservable.subscribe();
}
endJob() {
jobSubject.onNext(currentJob);
}
endDocument() {
jobSubject.onComplete();
jobObservable.??? // wait for the observable to complete.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment