Method UseStore
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
UseStore<TStore, TSel>(Store<TStore>, Func<TStore, TSel>, IEqualityComparer<TSel>?)
Subscribes to an external Store via a selector. Must be used inside Render() only.
public static TSel UseStore<TStore, TSel>(Store<TStore> store, Func<TStore, TSel> selector, IEqualityComparer<TSel>? comparer = null)
Parameters
storeStore<TStore>Store instance to subscribe to. Must not be null.
selectorFunc<TStore, TSel>Pure projection from the store snapshot to the value the component cares about. Must not be null.
comparerIEqualityComparer<TSel>Equality comparer used to detect changes. Defaults to Velvet.ObjectIsEqualityComparer<T> (reference equality for objects, NaN-aware for float/double). Pass System.Collections.Generic.EqualityComparer<T>.Default explicitly when value-equality skip is desired (e.g. record selectors with stable content).
Returns
- TSel
The selected value at the current store snapshot.
Type Parameters
TStoreStore snapshot type.
TSelSelected projection type returned to the component.