Skip to content
Source
Sign inSign up
TanStack/store
Open History to see the last commit

injectSelector.md

56 lines998 Bytes

function injectSelector<TState, TSelected>(
   source, 
   selector?, 
options?): Signal<TSelected>;

Defined in: packages/angular-store/src/injectSelector.ts:93

Selects a slice of state from an atom or store and returns it as an Angular signal.

This is the primary Angular read hook for TanStack Store.

Type Parameters

TState

TState

TSelected

TSelected = NoInfer<TState>

Parameters

source

SelectionSource<TState>

selector?

(state) => TSelected

options?

InjectSelectorOptions<TSelected>

Returns

Signal<TSelected>

Examples

readonly count = injectSelector(counterStore, (state) => state.count)
readonly doubled = injectSelector(countAtom, (value) => value * 2)