EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

Lifecycle Awareness

Open ueen opened this issue 4 years ago • 2 comments

Whats about the registering and unregistering, why cann't the @Subscribe function be Lifecycle Aware, registering on Class creation and unregistering on destruction, would be really neat if this could be added :)

ueen avatar Jan 13 '20 18:01 ueen

I guess you try writing your own LifecycleObserver. https://developer.android.com/topic/libraries/architecture/lifecycle#lc

https://github.com/greenrobot/EventBus/blob/6348f40f9901f813451791f9d11181be6eb49a32/EventBus/src/org/greenrobot/eventbus/EventBusLifecycleObserver.java#L9-L29

greenrobot-team avatar Jan 28 '20 12:01 greenrobot-team

Yea i resorted to LiveData, as I need to send an event from a background thread even if the app is not opend but after reopening the UI has to react to that event, I couldn't really achieve that with EventBus. LiveData isn't the cleanest solution for events, but it is extremely reliable. In my opinion this behavior would also greatly improve EventBus :)

ueen avatar Jan 28 '20 12:01 ueen