SmartEventBus是一个Android平台的消息总线框架,这是一款非常smart的消息总线框架,能让你定制自己的消息总线。
| 消息总线 | 延迟发送 | 有序接收消息 | Sticky | 生命周期感知 | 跨进程/APP | Customize(定制能力) | 线程分发 |
|---|---|---|---|---|---|---|---|
| EventBus | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ |
| RxBus | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ |
| LiveEventBus | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
| SmartEventBus | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
想了解更多?请点击:全面了解Android消息总线
@SmartEvent(keys = {"event1", "event2", "event3"}) public class MessageEvent { public String msg; public MessageEvent(String msg) { this.msg = msg; } } @SmartEventConfig(packageName = "yourPackageName", busName = "YourClassName") public class BaseEventConfig { } - 配置之后,会生成定制消息总线:yourPackageName.YourClassName
- 也可以不配置,生成默认命名DefaultSmartEventBus的消息总线
MySmartEventBus .event1() .observe(this, new Observer<MessageEvent>() { @Override public void onChanged(@Nullable MessageEvent event) { } }); MySmartEventBus .event1() .post(new MessageEvent("msg from smarteventbus")); implementation 'com.jeremyliao:smart-event-bus-base:0.0.1' annotationProcessor 'com.jeremyliao:smart-event-bus-compiler:0.0.2' -dontwarn com.jeremyliao.liveeventbus.** -keep class com.jeremyliao.liveeventbus.** { *; } 