Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fredevteam/tkeventbusmodule
TKComponentization EventBus module
https://github.com/fredevteam/tkeventbusmodule
eventbus ios macosx swift4
Last synced: about 9 hours ago
JSON representation
TKComponentization EventBus module
- Host: GitHub
- URL: https://github.com/fredevteam/tkeventbusmodule
- Owner: FredevTeam
- License: mit
- Created: 2019-08-11T07:29:06.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-26T10:30:37.000Z (almost 4 years ago)
- Last Synced: 2024-09-25T01:14:01.766Z (about 11 hours ago)
- Topics: eventbus, ios, macosx, swift4
- Language: Swift
- Size: 51.8 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TKEventBusModule
[![CI Status](https://img.shields.io/travis/zhuamaodeyu/TKEventBusModule.svg?style=flat)](https://travis-ci.org/zhuamaodeyu/TKEventBusModule)
[![Version](https://img.shields.io/cocoapods/v/TKEventBusModule.svg?style=flat)](https://cocoapods.org/pods/TKEventBusModule)
[![License](https://img.shields.io/cocoapods/l/TKEventBusModule.svg?style=flat)](https://cocoapods.org/pods/TKEventBusModule)
[![Platform](https://img.shields.io/cocoapods/p/TKEventBusModule.svg?style=flat)](https://cocoapods.org/pods/TKEventBusModule)[中文文档](./Example/README-ZH.md)
## ExampleTo run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
TKEventBusModule is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'TKEventBusModule'
```## Example
### 1. Subscriber1. `Import`
```
import TKEventBusModule
```2. subscribe for NSObject subclass or add protocol `TKEventSubscriber`
```
self.bus.subscribe(on: .login) { (event) in
debugPrint("单独事件响应")
debugPrint("测试时间:\(CACurrentMediaTime() - (self.start ?? 0))")
}
```
3. custom Subscriber```
struct Present: TKEventSubscriber {}
private var present = Present()present.bus.subscribe(on: .login) { (event) in
debugPrint("单独事件响应")
debugPrint("测试时间:\(CACurrentMediaTime() - (self.start ?? 0))")
}
```
#### Pause/ restore1. Pause
```
self.bus.pauseSubscribe(on: .login)
```
2. Restore
```
self.bus.restoreSubscribe(on: .login)
```### 2. Publish.
1. Create Event need name and data object.```
let event = TKEvent.init(.login, data: "事件1", jsonString:"")
TKEventBus.instance.publish(event)
```
__Note:__ if use from Componentization,need use `init(_ name: , data:, jsonString:)`##### Notification support
```
let notification = Notification.init(name: .notification, object: "系统测试通知", userInfo: nil)
TKEventBus.instance.publish(notification)
```
__Note:__ protocol property jsonString is not use from this is Notification , data property is default return object or userInfo## Author
zhuamaodeyu, [email protected]
## License
TKEventBusModule is available under the MIT license. See the LICENSE file for more info.