MGLObservable
@protocol MGLObservable
The MGLObservable
protocol declares methods that conforming classes should
implement should they want to observe low-level events of type MGLEvent
.
Currently only MGLMapView
implements MGLObservable
.
-
Subscribes an
MGLObserver
to a provided set of event types.MGLObservable
will hold a strong reference to anMGLObserver
instance, therefore, in order to stop receiving notifications (and to avoid memory leaks), the caller must call unsubscribe with theMGLObserver
instance used for the initial subscription.Declaration
Objective-C
- (void)subscribeForObserver:(nonnull MGLObserver *)observer events:(nonnull NSSet<MGLEventType> *)events;
Swift
func subscribe(for observer: MGLObserver, events: Set<MGLEventType>)
Parameters
observer
an MGLObserver
events
a set of event types to subscribe to.
-
Unsubscribes an
MGLObserver
from a provided set of event types.Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer events:(nonnull NSSet<MGLEventType> *)events;
Swift
func unsubscribe(for observer: MGLObserver, events: Set<MGLEventType>)
Parameters
observer
an MGLObserver
events
a set of event types to unsubscribe from.
-
Unsubscribes an
MGLObserver
from all events (and release the strong reference).Declaration
Objective-C
- (void)unsubscribeForObserver:(nonnull MGLObserver *)observer;
Swift
func unsubscribe(for observer: MGLObserver)
Parameters
observer
an MGLObserver