CachedValueTypedNotification
open class CachedValueTypedNotification<A> : TypedNotification<A>
Derivation of TypedNotification that remembers the last post value and will use that for any register calls
that happen after the post call.
-
The last value given in a
postcall.Declaration
Swift
public private(set) var cachedValue: A? { get } -
Post a notification containing the given value.
Declaration
Swift
override open func post(value: A)Parameters
valuethe value to convey to registered observers
-
Forget any cached value.
Declaration
Swift
public func clear() -
Register a closure to invoke when
postis called. Note that ifcachedValueis not nil, the closure will be called immediately.Declaration
Swift
override open func registerOnAny(block: @escaping (A) -> Void) -> NotificationObserverParameters
blockthe closure to invoke
Return Value
value that will unregister the block if it is no longer held
-
Register a closure to invoke when
postis called.Declaration
Swift
override open func registerOnMain(block: @escaping (A) -> Void) -> NotificationObserverParameters
blockthe closure to invoke on the main thread
Return Value
value that will unregister the block if it is no longer held
View on GitHub
CachedValueTypedNotification Class Reference