Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ucodeustory/eventdriver
发送事件,不需要关心接收者的生命周期
https://github.com/ucodeustory/eventdriver
Last synced: 5 days ago
JSON representation
发送事件,不需要关心接收者的生命周期
- Host: GitHub
- URL: https://github.com/ucodeustory/eventdriver
- Owner: UCodeUStory
- Created: 2019-03-28T03:22:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-24T03:51:38.000Z (over 5 years ago)
- Last Synced: 2023-08-25T03:28:41.572Z (about 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 294 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EventDriver
在MVVM模式中,我们使用LiveData来实现通信,好处是可以通过生命周期去取消订阅
在实际开发中,我们事件需要在组件的onDestory前都可以接受到消息,并且不需要每次订阅都得到最新的消息
EventDriver 设计就是解决这一问题
### 订阅消息
EventDriver.find("tom").observe(this, Observer {
})
### 发送消息EventDriver.notify("tom") of "goodMorning"