Observable
public class Observable<T>: NSObject
Class in charge of registering, removing and iterating over a list of observers.
-
The array of registered observers
Declaration
Swift
public var observers: [Int: T]!
-
The current id of the last created observer
Declaration
Swift
public var currentId: Int
-
Initializes a new Observable and its properties.
Declaration
Swift
public override init()
Return Value
A configured instance of an Observable.
-
Registers an observer.
Declaration
Swift
public func registerObserver(observer: T) -> Int
Parameters
observer
The observer to be registered.
Return Value
The id of the registered observer.
-
Removes a registered observer.
Declaration
Swift
public func removeObserver(id: Int)
Parameters
id
The id of the observer to be removed.
-
Iterates over the observers and applies a function to them.
Declaration
Swift
public func forEach(fn: (T) -> Void)
Parameters
fn
The function to apply to every registered observer.