EventBus, register and registerSticky method

懵懂的女人 提交于 2019-12-22 01:45:56

问题


I use greenrobot EventBus library to send data between two fragments in my android app and I want to know what is the diffeence between register(Object b) method and registerSticky(Object object) method?


回答1:


EventBus allows you to post events that are "sticky" and by that EventBus understands events that "stick to the eventbus" for future access.

If you post a normal event when there are no subscribers registered at the moment of sending, this event will be discarded.

You can post a sticky event though, even if there are no subscribers to receive that at the moment, and it won't be discarded (unless there is another sticky event posted in the future). When a subscriber registers with registerSticky the delivery of the last sticky event is also triggered.



来源:https://stackoverflow.com/questions/28051317/eventbus-register-and-registersticky-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!