EventBus 黏性事件的postSticky
/**
* Posts the given event to the event bus and holds on to the event (because it is sticky). The most recent sticky
* event of an event's type is kept in memory for future access by subscribers using {@link Subscribe#sticky()}.
*/
public void postSticky(Object event) {
synchronized (stickyEvents) {
stickyEvents.put(event.getClass(), event);
}
// Should be posted after it is putted, in case the subscriber wants to remove immediately
post(event);
}
将事件类型添加到stickyEvents中,是一个Map,Key是事件类型,Value是事件对象;
然后调用post方法;对已经注册过得方法发送订阅事件;
这里我有一点疑惑,就是这个注释:
// Should be posted after it is putted, in case the subscriber wants to remove immediately
翻译过来就是:在put到stickyEvents之后应该立即post出去,防止订阅者想要立刻移除事件;
没明白是什么意思…