From bfd497550e97b41f55ade6fce82198df5caf6327 Mon Sep 17 00:00:00 2001 From: BugRui <54742263+BugRui@users.noreply.github.com> Date: Tue, 12 May 2020 10:03:07 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2634e23..ee0fbed 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ allprojects { ``` #### Step 2. Add the dependency ``` - implementation 'com.github.BugRui:LiveDataBus:1.2.0' + implementation 'com.github.BugRui:LiveDataBus:1.2.1' ``` From 11b51e49eabc2d08dd085620649f43ecd143ce04 Mon Sep 17 00:00:00 2001 From: BugRui <54742263+BugRui@users.noreply.github.com> Date: Tue, 12 May 2020 10:08:31 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee0fbed..a22fef0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # LiveDataBus [![version](https://jitpack.io/v/BugRui/LiveDataBus.svg)](https://jitpack.io/#BugRui/LiveDataBus/1.2.0) ##### 基于LiveData实现事件总线,具备生命周期感知,感知确保LiveData仅更新处于活动生命周期状态的应用程序组件观察者, -##### 支持粘性,消息发送后订阅也能收到发出的消息 -##### 注意!!!消息发送后,只有处于活动生命周期状态才会收到发出的消息。 +##### 支持粘性,消息发送后订阅也能收到发出的消息,但是只能收到订阅前发送的最后一条消息 + + ### 集成 @@ -24,11 +25,17 @@ allprojects { ### 订阅普通事件消息 ``` - +//仅更新处于活动生命周期状态的应用程序组件观察者 LiveDataBus.with("tag") .observe(this, Observer { toast("收到普通事件消息:${it.toString()}") }) + +//不受生命周期的影响,只要数据更新就会收到通知 +LiveDataBus.with("tag") + .observeForever(this, Observer { + toast("收到普通事件消息:${it.toString()}") + }) ``` ### 发送普通事件消息 @@ -38,6 +45,14 @@ LiveDataBus.with("tag") ``` ## 订阅粘性事件消息 ``` + +//仅更新处于活动生命周期状态的应用程序组件观察者 +LiveDataBus.withStickiness("tag") + .observe(this, Observer { + toast("收到粘性事件消息:${it.toString()}") + }) + +//不受生命周期的影响,只要数据更新就会收到通知 LiveDataBus.withStickiness("tag") .observe(this, Observer { toast("收到粘性事件消息:${it.toString()}") From b6614194f0ca874d7a7bafcb4508b904f782cafb Mon Sep 17 00:00:00 2001 From: BugRui <54742263+BugRui@users.noreply.github.com> Date: Tue, 12 May 2020 10:08:57 +0800 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a22fef0..edd2643 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ LiveDataBus.withStickiness("tag") //不受生命周期的影响,只要数据更新就会收到通知 LiveDataBus.withStickiness("tag") - .observe(this, Observer { + .observeForever(this, Observer { toast("收到粘性事件消息:${it.toString()}") }) ```