MBMObservable
@interface MBMObservable : NSObject
Observable class provides basic Publish&Subscribe functionality. Classes that extend this functionality and capable of generating events, have to specify event types and corresponding data format for an event.
-
Subscribes an Observer to a provided list of event types. Observable will hold a strong reference to an Observer instance, therefore, in order to stop receiving notifications, caller must call unsubscribe with an Observer instance used for an initial subscription.
Declaration
Objective-C
- (void)subscribeForObserver:(nonnull id<MBMObserver>)observer events:(nonnull NSArray<NSString *> *)events;
Parameters
observer
an Observer
events
an array of event types to be subscribed to.
-
Unsubscribes an Observer to a provided list of event types. Observable will hold a strong reference to an Observer instance, therefore, in order to stop receiving notifications, caller must call unsubscribe with an Observer instance used for an initial subscription.
Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull id<MBMObserver>)observer events:(nonnull NSArray<NSString *> *)events;
Parameters
observer
an Observer
events
an array of event types to be unsubscribed to.
-
Unsubscribes an Observer from all events.
Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull id<MBMObserver>)observer;
Parameters
observer
an Observer