Skip to content

基于LiveData实现的一款不用反注册,不会内存泄露的轻量级消息总线框架,支持订阅普通事件消息和粘性事件

Notifications You must be signed in to change notification settings

fmtjava/LiveDataBus

Repository files navigation

LiveDataBus version

基于LiveData实现的一款不用反注册,不会内存泄露的轻量级消息总线框架,支持订阅普通事件消息和粘性事件

How to

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

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")

About

基于LiveData实现的一款不用反注册,不会内存泄露的轻量级消息总线框架,支持订阅普通事件消息和粘性事件

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages