Observer
open class Observer : IObserver
A base IObserver implementation.
An Observer is an object that encapsulates information
about an interested object with a method that should
be called when a particular INotification is broadcast.
In PureMVC, the Observer class assumes these responsibilities:
- Encapsulate the notification (callback) method of the interested object.
- Encapsulate the notification context (this) of the interested object.
- Provide methods for setting the notification method and context.
- Provide a method for notifying the interested object.
@see org.puremvc.swift.multicore.core.View View
@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
-
Declaration
Swift
public var notifyMethod: ((_ notification: INotification) -> ())? -
Declaration
Swift
weak public var notifyContext: AnyObject? -
Constructor.
The notification method on the interested object should take one parameter of type
INotificationDeclaration
Swift
public init(notifyMethod: ((INotification) -> ())?, notifyContext: AnyObject?)Parameters
notifyMethodthe notification method of the interested object
notifyContextthe notification context of the interested object
-
Notify the interested object.
Declaration
Swift
open func notifyObserver(_ notification: INotification)Parameters
notificationthe
INotificationto pass to the interested object’s notification method. -
Compare an object to the notification context.
Declaration
Swift
open func compareNotifyContext(_ object: AnyObject) -> BoolParameters
objectthe object to compare
Return Value
boolean indicating if the object and the notification context are the same
Observer Class Reference