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
post
call.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
value
the value to convey to registered observers
-
Forget any cached value.
Declaration
Swift
public func clear()
-
Register a closure to invoke when
post
is called. Note that ifcachedValue
is not nil, the closure will be called immediately.Declaration
Swift
override open func registerOnAny(block: @escaping (A) -> Void) -> NotificationObserver
Parameters
block
the closure to invoke
Return Value
value that will unregister the block if it is no longer held
-
Register a closure to invoke when
post
is called.Declaration
Swift
override open func registerOnMain(block: @escaping (A) -> Void) -> NotificationObserver
Parameters
block
the closure to invoke on the main thread
Return Value
value that will unregister the block if it is no longer held