I'm using GreenRobot's EventBus version 3.0. And there's a section on the docs which says that we can post sticky events, and to receive those events we have to subscribe like this:
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEvent(MessageEvent event) {
// Do something with the message.
// Is the event removed from the bus on this method?
}
So, my question is: Once the subscriber receives the sticky event, are they removed from the bus automatically, or do I have to remove them manually?
Note: I know I can remove them manually in any other place of my code using the following line:
EventBus.getDefault().removeStickyEvent(stickyEvent);
But I want to know if I really need to do that inside the subscriber method.
No, they are not removed.
However, if you are sticking a message just to remove it when somebody reads it, what you are describing is a queue.
Sticky events are like sticky posts in a bulletin board: they are meant to stay "at top" and be viewed by everybody for a period of time.