基于LiveData实现的一款不用反注册,不会内存泄露的轻量级消息总线框架,支持订阅普通事件消息和粘性事件
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.fmtjava:LiveDataBus:1.0.1'
LiveDataBus.with<User>("login").observe(this, {
tv_text.text = it.name
})
LiveDataBus.with<User>("login").postData(user)
LiveDataBus.with<String>("name").observeStick(this, {
tv_text.text = it
})
LiveDataBus.with<String>("name").postStickData("fmt")