InMemoryStorage
open class InMemoryStorage<StoredValue> : Storage
Storage that stores values in memory; values will not be persisted between app launches or instances of InMemoryStorage.
-
The type the
InMemoryStoragecan store.Declaration
Swift
public typealias Value = StoredValue -
Create a new empty instance of
InMemoryStorage.Declaration
Swift
public init() -
Store the provided value against the specified key.
Declaration
Swift
open func storeValue(_ value: StoredValue, key: String)Parameters
valueThe value to store.
keyThe key to store the value against.
-
Removes the value for the provide key.
Declaration
Swift
open func removeValue(for key: String)Parameters
keyThe key of the value to be removed.
-
Returns the value for the provided key, or
nilif the value does not exist.Declaration
Swift
open func retrieveValue(for key: String) -> StoredValue?Parameters
keyThe key of the value to retrieve.
Return Value
The stored value, or
nilif the a value does not exist for the specified key. -
Add a closure that will be called when the specified key is updated.
Declaration
Swift
open func addUpdateListener(forKey key: String, updateListener: @escaping UpdateListener) -> AnyCancellableParameters
keyThe key to listen for changes to.
updateListenerThe 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
InMemoryStorage Class Reference