Skip to content

Instantly share code, notes, and snippets.

@kaushikgopal
Created June 26, 2016 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaushikgopal/66d5b3d1a8f630811371910150dca43d to your computer and use it in GitHub Desktop.
Save kaushikgopal/66d5b3d1a8f630811371910150dca43d to your computer and use it in GitHub Desktop.
Blog post snippet for implementing event bus
// this is the middleman object
public class RxBus {
private final Subject<Object, Object> _bus = new SerializedSubject<>(PublishSubject.create());
public void send(Object o) {
_bus.onNext(o);
}
public Observable<Object> toObserverable() {
return _bus;
}
}
@yashasvigirdhar
Copy link

Hi Kaushik,

Thanks for the snippet.

Should't it be Subject<Object> _bus ?

@yashasvigirdhar
Copy link

yashasvigirdhar commented Mar 5, 2018

Also, SerializedSubject is not public anymore ( ref)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment