To run the example project, clone the repo, and run pod install
from the Example directory first.
TKEventBusModule is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TKEventBusModule'
-
Import
import TKEventBusModule
-
subscribe for NSObject subclass or add protocol
TKEventSubscriber
self.bus.subscribe(on: .login) { (event) in debugPrint("单独事件响应") debugPrint("测试时间:\(CACurrentMediaTime() - (self.start ?? 0))") }
-
custom Subscriber
struct Present: TKEventSubscriber { } private var present = Present() present.bus.subscribe(on: .login) { (event) in debugPrint("单独事件响应") debugPrint("测试时间:\(CACurrentMediaTime() - (self.start ?? 0))") }
-
Pause
self.bus.pauseSubscribe(on: .login)
-
Restore
self.bus.restoreSubscribe(on: .login)
-
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:)
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
zhuamaodeyu, [email protected]
TKEventBusModule is available under the MIT license. See the LICENSE file for more info.