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) throwsParameters
keyThe key of the value to remove.
-
Retrieve the value for the provided key.
Parameters
keyThe key of the value to retrieve.
Return Value
The stored value, or
nilif 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) -> AnyCancellableParameters
keyThe key to subscribe to changes to.
updateListenerA 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.
View on GitHub
Storage Protocol Reference