Skip to content

gets

gets<S, A>(f): State<S, A>

Defined in: Core/State.ts:60

Reads a projection of the state without modifying it. Equivalent to pipe(State.get(), State.map(f)) but more direct.

S

A

(s) => A

State<S, A>

type AppState = { count: number; label: string };
const readCount: State<AppState, number> = State.gets(s => s.count);
State.run({ count: 5, label: "x" })(readCount); // [5, { count: 5, label: "x" }]