I'm using the GreenRobot EventBus lib on Android.
Could someone tell me, what's best practice for calling the removeStickyEvent(...)? Up-Action, back button pressed, ...?
Thank you guys.
To answer your question about the Event object staying in memory: only the last sticky event posted stays in memory for each given type.
Take a look at the source here.
Basically to summarize: Eventbus keeps a map of stickyEvents with the key being class type and the value being the field. So when a new sticky event is posted with
EventBus.postSticky(event) the event posted overwrites the old event. So I think you are safe from building up many sticky events.
I was worried about that also. I wish it was explained better in the docs but at least its open source so we can look inside and see whats happening.
I guess to answer your question more completely. When should you remove a sticky event? When you don't want calls to get the sticky event to not return anything. When exactly that is is an application specific requirement. Good luck.