eventbus指定接收者
来源:互联网 发布:手机淘宝怎么举报店铺 编辑:程序博客网 时间:2024/06/03 22:47
http://greenrobot.org/eventbus/documentation/priorities-and-event-cancellation/
思路:设置订阅者的优先级,优先级高的接收事件处理,取消事件,事件无法继续往下传递,达到指定接收者的目的。
1.Subscriber Priorities
You may change the order of event delivery by providing a priority to the subscriber during registration.
@Subscribe(priority = 1); //设置优先级
public void onEvent(MessageEvent event) {
…
}
Within the same delivery thread (ThreadMode), higher priority subscribers will receive events before others with a lower priority.
2.Cancelling event delivery
You may cancel the event delivery process by calling cancelEventDelivery(Object event) from a subscriber’s event handling method. Any further event delivery will be cancelled: subsequent subscribers won’t receive the event.
// Called in the same thread (default)
@Subscribe
public void onEvent(MessageEvent event){
// Process the event
…
EventBus.getDefault().cancelEventDelivery(event) ; //取消事件传递
}
Events are usually cancelled by higher priority subscribers. Cancelling is restricted to event handling methods running in posting thread ThreadMode.PostThread.
- eventbus指定接收者
- eventbus指定接收者
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- EventBus
- Eventbus
- EventBus
- EventBus
- 用户行为数据采集核心思维(APP、web数据采集/埋点)
- 游戏登录流程
- struts2 源码解析
- Python 异常处理
- HDU 4552 怪盗基德的挑战书 【EXKMP】
- eventbus指定接收者
- Winform选择目录路径与选择文件路径
- css样式分类及背景样式
- javascript初级
- 学编程上这些网站就够了
- 进程池总结
- 安装mmseg出错 config.status: error: cannot find input file: src/Makefile.in
- MapReduce任务Namenode DataNode Jobtracker Tasktracker之间的关系
- uart——51程序