@ngrx/signals
Version:
Reactive Store and Set of Utilities for Angular Signals
24 lines (23 loc) • 1.27 kB
TypeScript
import { Injector, Signal, WritableSignal } from '@angular/core';
export declare const STATE_SOURCE: unique symbol;
export type WritableStateSource<State extends object> = {
[STATE_SOURCE]: {
[K in keyof State]: WritableSignal<State[K]>;
};
};
export type StateSource<State extends object> = {
[STATE_SOURCE]: {
[K in keyof State]: Signal<State[K]>;
};
};
export type PartialStateUpdater<State extends object> = (state: State) => Partial<State>;
export type StateWatcher<State extends object> = (state: NoInfer<State>) => void;
export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
export declare function isWritableStateSource<State extends object>(stateSource: StateSource<State>): stateSource is WritableStateSource<State>;
export declare function patchState<State extends object>(stateSource: WritableStateSource<State>, ...updaters: Array<Partial<NoInfer<State>> | PartialStateUpdater<NoInfer<State>>>): void;
export declare function getState<State extends object>(stateSource: StateSource<State>): State;
export declare function watchState<State extends object>(stateSource: StateSource<State>, watcher: StateWatcher<State>, config?: {
injector?: Injector;
}): {
destroy(): void;
};