Storage
public protocol Storage : AnyObject
A protocol that defines the interface to store, remove, and retrieve values by a string key.
-
The type of the keys used to reference values in the storage.
Declaration
Swift
associatedtype Key
-
The type of values that can be stored.
Declaration
Swift
associatedtype Value
-
A closure that will be called when an update occurs.
Declaration
Swift
typealias UpdateListener = (Value?) -> Void
-
Remove the value for the provided key.
Declaration
Swift
func removeValue(for key: Key) throws
Parameters
key
The key of the value to remove.
-
Retrieve the value for the provided key.
Parameters
key
The key of the value to retrieve.
Return Value
The stored value, or
nil
if no value is associated with the key. -
Add a closure that will be called when a value is updated.
Declaration
Swift
func addUpdateListener(forKey key: Key, updateListener: @escaping UpdateListener) -> AnyCancellable
Parameters
key
The key to subscribe to changes to.
updateListener
A closure to call when an update occurs.
Return Value
An object that represents the closure’s subscription to changes. This object must be retained by the caller.