kaushikgopal / RxJava-Android-Samples

Learning RxJava for Android by example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sticky event bus

SmartDengg opened this issue · comments

Hi.
First of all, thank you for the great samples, That's awesome!

I would like to get some advice. I really want to know how to implement sticky event with Rxbus. Any operator can reach it? I can't find any example for that, should i custom operator by .lift( )? If you feel it, what would you do?

I'm really really really confused. : (

Thanks.

you may what to use BehaviorSubject as RxHub middleman engine.
ex:
private final Subject<Object, Object> _bus = new SerializedSubject<>(BehaviorSubject.create());

you may also take a look into https://github.com/apptik/rxHub which was particularly built for Pub-Sub type of architecture.

@djodjoni is totally right. Simply changing from a PublishSubject -> BehaviorSubject should achieve what you need.

Note that i've upgraded the examples to use Jake Wharton's RxRelay so instead of a PublishRelay you're looking at a BehaviorRelay.

Let me know if you have any other questions.