我开始使用EventBus 3.0.0。
我有 3 个粘性事件要从服务发送到活动:
- 行动开始
- 行动进度
- 动作完成
我正在听主线程上的事件:
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void on...Event(... event) {
...
}
服务按顺序发送事件:started-progressN-..-progressM-finished
订阅的Activity根据事件更新UI。
活动轮换后,我希望按照发送的顺序获得粘性事件,否则会破坏 ui(因为在开始时将进度设置为 0)。EventBus 是否保证事件顺序(假设我对所有这些事件使用相同的 EventBus、相同的接收器线程、相同的订阅者)?
根据我的测试,不能保证这是功能/问题,是吗?
旋转前:
07-27 11:27:55.254 27910-27910/ app D/App﹕ status Compilation started ...
07-27 11:27:55.254 27910-27910/ app D/App﹕ compile progress 0%
07-27 11:27:55.354 27910-27910/ app D/App﹕ compile progress 20%
07-27 11:27:55.354 27910-27910/ app D/App﹕ compile progress 30%
07-27 11:27:55.354 27910-27910/ app D/App﹕ compile progress 40%
07-27 11:27:55.844 27910-27910/ app D/App﹕ compile progress 50%
旋转后(重新发送粘性事件):
07-27 11:27:59.554 27910-27910/ app D/App﹕ compile progress 50%
07-27 11:27:59.554 27910-27910/ app D/App﹕ status Compilation started ...