Create an observable for an event loop Create an observable for an event loop multithreading multithreading

Create an observable for an event loop


What you're looking for is a Subject. These act as both Observer and Observables. For example a ReplaySubject will replay all events sent to it to all subscribers.

Subject<String> replaySubject = ReplaySubject.create();replaySubject.subscribe(s -> System.out.println(s));// elsewhere...replaySubject.onNext("First");replaySubject.onNext("Second");replaySubject.onComplete();