Kotlin 中使用 EventBus

2017-08-22  本文已影响0人  Obadiah

换到 Kotlin 后,之前的 EventBus 不能正常用,发现这个还挺好用的。

依赖:

compile 'com.eightbitlab:rxbus:1.0.2'

注意事项:

注册和接收事件:

Bus.observe<UpdatePersonInfoEvent>()
        .subscribe {
            personInfo(it)
        }
        .registerInBus(this)

取消注册:

Bus.unregister(this)

发送事件:

Bus.send(UpdatePersonInfoEvent(true))
上一篇 下一篇

猜你喜欢

热点阅读