nucleux
Version:
Simple, atomic hub for all your React application's state management needs. No providers, no boilerplate, just state that works.
19 lines (18 loc) • 1.05 kB
TypeScript
import { AtomInterface, AtomMemoizationOptions, AtomOptions, ReadOnlyAtomInterface, SupportedStorage } from './Atom';
import { Injectable } from './Injectable';
import { StoreInterface } from './types';
type UnwrappedValue<T> = T extends ReadOnlyAtomInterface<infer R> ? R : T;
type UnwrappedValues<T extends Array<ReadOnlyAtomInterface<any>>> = {
[P in keyof T]: UnwrappedValue<T[P]>;
};
declare abstract class Store extends Injectable implements StoreInterface {
private subscriptions;
protected storage?: SupportedStorage;
constructor();
protected atom<V>(initialValue: V, options?: AtomOptions<V>): AtomInterface<V>;
protected watchAtom<V>(atom: ReadOnlyAtomInterface<V>, callback: (value: V, previousValue?: V) => void, immediate?: boolean): void;
protected deriveAtom<V, A extends ReadOnlyAtomInterface<any>[] | []>(sourceAtoms: A, transformer: (...args: UnwrappedValues<A>) => V, memoization?: AtomMemoizationOptions<V>): ReadOnlyAtomInterface<V>;
enableDebug(): void;
destroy(): void;
}
export { Store };