EventBus-iOS

码农软件 · 软件分类 · 其他(Others) · 2019-07-25 08:27:41

软件介绍

EventBus for iOS  non-ARC

有两种事件: 1. SyncEvent  类似于使用NotificationCenter发出的通知,不会存储在EventBus上,              事件发生时会直接调用同步事件订阅者(id< EventSyncSubscriber >)。 2. AsyncEvent 异步事件,具有一定的生命周期(event.life),会存储在EventBus上(EventBus具有一定的容量)              异步事件需要异步订阅者(id< EventAsyncSubscriber >)主动去读取事件。

使用:

订阅者:

  1. 标记自己实现< EventAsyncSubscriber > 或 < EventSyncSubscriber >接口, 表明自己为订阅者;

  2. 在适当时刻使用宏EVENT_SUBSCRIBE(self,eventName)订阅eventName事件,一般可以在init 或 controller的 viewDidLoad方法中;

  3. 事件发生时会回调< EventSubscriber >接口中的方法- (void)eventOccurred: (NSString *)eventName event:(Event *)event, 对于异步订阅者,需要使用EVENT_CHECK(self,eventName)从EventBus中读取事件,如果有事件,eventOccurred方法会立刻得到调用。

  4. 在适当时刻使用宏EVENT_UNSUBSCRIBE(self,eventName)解订eventName事件,一般可以在dealloc中.

发布者:

  1. 标记自己实现< EventAsyncPublisher > 或 < EventSyncPublisher >接口,表明自己为发布者;

  2. 在事件发生时使用宏EVENT_PUBLISH(self,eventName)发布eventName事件,或使用EVENT_PUBLISH_WITHDATA(self,eventName,eventData) 在发布事件同时传递eventData数据.

另外:  代码中使用了 MAZeroingWeakRef 来实现弱引用, 地址: https://github.com/mikeash/MAZeroingWeakRef

本文地址:https://codercto.com/soft/d/10886.html

Network Algorithmics,

Network Algorithmics,

George Varghese / Morgan Kaufmann / 2004-12-29 / USD 75.95

In designing a network device, you make dozens of decisions that affect the speed with which it will perform - sometimes for better, but sometimes for worse. "Network Algorithmics" provides a complete......一起来看看 《Network Algorithmics,》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换