kaushikgopal / RxJava-Android-Samples

Learning RxJava for Android by example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rxbus + Sticky Events?

sirvon opened this issue · comments

What about making the events sticky?

If I use rxbus with android's sharing mechnism how will I get the event in the activity where
the shared info is received.

The event will be sent before the activity is opened...do I have to persist the event?
would'nt that make a bus irrelevant?

Sticky events can be achieved by way of using a different Subject in your RxBus implementation. For e.g. use a BehaviorSubject

That would make only the last event posted sticky regardless of event type. In eventBus it used to be sticky per evenType .. how would I handle that? Hashmap of eventType, PublishSubject? Feels wrong..

@ursusursus - honestly, I would find a way to workaround needing to use an event bus at that point altogether. The Hashmap would work, but dang that would be pretty heavy handed. I would definitely explore finding alternative ways of handling that usecase at that point.