Table of Contents

Method Select

Namespace
Velvet
Assembly
Velvet.Docs.dll

Select<T>(Func<TState, T>, Action<T, T>, IEqualityComparer<T>?, bool)

Subscribes to a selected slice with a (currentSlice, previousSlice) signature. The listener fires only when the selected slice changes under the given comparer.

public IDisposable Select<T>(Func<TState, T> selector, Action<T, T> observer, IEqualityComparer<T>? comparer = null, bool fireImmediately = false)

Parameters

selector Func<TState, T>

Pure projection from the store snapshot. Must not be null.

observer Action<T, T>

Invoked with (currentSlice, previousSlice) on each change. Must not be null.

comparer IEqualityComparer<T>

Equality comparer that decides whether two consecutive slices are equal. Defaults to reference (Object.is) equality, the same default used by UseStore<TStore, TSel>(Store<TStore>, Func<TStore, TSel>, IEqualityComparer<TSel>?). Pass Sequence<T>() to compare sequence slices element-by-element instead.

fireImmediately bool

When true, fires the observer synchronously with (selector(Current), selector(Current)) before returning. Default is false.

Returns

IDisposable

Type Parameters

T

Selected projection type.