MBMObservable
@interface MBMObservable : NSObject
The observable
interface 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 array of event types. Theobservable
will hold a strong reference to anobserver
instance, therefore, in order to stop receiving notifications, caller must callunsubscribe
with anobserver
instance used for an initial subscription.Declaration
Objective-C
- (void)subscribeForObserver:(nonnull id<MBMObserver>)observer events:(nonnull NSArray<NSString *> *)events;
Parameters
observer
An
observer
that will be subscribed to a given events.events
An array of event types to be subscribed to.
-
Unsubscribes an
observer
from a provided array of event types.Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull id<MBMObserver>)observer events:(nonnull NSArray<NSString *> *)events;
Parameters
observer
An
observer
that will be unsubscribed from a given events.events
An array of event types to be unsubscribed from.
-
Unsubscribes an
observer
from all events.Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull id<MBMObserver>)observer;
Parameters
observer
An
observer
that will be unsubscribed from all previously subscribed events.