Table of Contents

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

store Store<TStore>

Store instance to subscribe to. Must not be null.

selector Func<TStore, TSel>

Pure projection from the store snapshot to the value the component cares about. Must not be null.

comparer IEqualityComparer<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

TStore

Store snapshot type.

TSel

Selected projection type returned to the component.