Storage
Storage system interfaces and factory types.
StorageSystem<T>
Section titled “StorageSystem<T>”Interface for storage systems.
Properties
Section titled “Properties”| Name | Type | Description |
|---|---|---|
get | () => T | Get the current value. |
set | (value: T) => void | Set a new value. |
subscribe | (listener: Listener<T>) => () => void | Subscribe to value changes. |
StorageFactory<T>
Section titled “StorageFactory<T>”Factory function for creating storage systems.
Signature
Section titled “Signature”type StorageFactory<T> = (initial: T) => StorageSystem<T>createStorage
Section titled “createStorage”Creates a storage system from a factory.
Signature
Section titled “Signature”import { createStorage, StorageFactory } from '@reaxium/core';
function createStorage<T>( factory?: StorageFactory<T>): (initial: T) => StorageSystem<T>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
factory | StorageFactory<T> | (Optional) Storage factory. |
Example
Section titled “Example”const storage = createStorage()(0);