Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiLi5 committed May 18, 2020
2 parents 7b35dd6 + b661419 commit 3959b84
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# LiveDataBus [![version](https://jitpack.io/v/BugRui/LiveDataBus.svg)](https://jitpack.io/#BugRui/LiveDataBus/1.2.0)

##### 基于LiveData实现事件总线,具备生命周期感知,感知确保LiveData仅更新处于活动生命周期状态的应用程序组件观察者,
##### 支持粘性,消息发送后订阅也能收到发出的消息
##### 注意!!!消息发送后,只有处于活动生命周期状态才会收到发出的消息。
##### 支持粘性,消息发送后订阅也能收到发出的消息,但是只能收到订阅前发送的最后一条消息




### 集成
Expand All @@ -18,17 +19,23 @@ allprojects {
```
#### Step 2. Add the dependency
```
implementation 'com.github.BugRui:LiveDataBus:1.2.0'
implementation 'com.github.BugRui:LiveDataBus:1.2.1'
```


### 订阅普通事件消息
```
//仅更新处于活动生命周期状态的应用程序组件观察者
LiveDataBus.with("tag")
.observe(this, Observer {
toast("收到普通事件消息:${it.toString()}")
})
//不受生命周期的影响,只要数据更新就会收到通知
LiveDataBus.with("tag")
.observeForever(this, Observer {
toast("收到普通事件消息:${it.toString()}")
})
```

### 发送普通事件消息
Expand All @@ -38,10 +45,18 @@ LiveDataBus.with("tag")
```
## 订阅粘性事件消息
```
//仅更新处于活动生命周期状态的应用程序组件观察者
LiveDataBus.withStickiness("tag")
.observe(this, Observer {
toast("收到粘性事件消息:${it.toString()}")
})
//不受生命周期的影响,只要数据更新就会收到通知
LiveDataBus.withStickiness("tag")
.observeForever(this, Observer {
toast("收到粘性事件消息:${it.toString()}")
})
```

### 发送粘性事件消息
Expand Down

0 comments on commit 3959b84

Please sign in to comment.