nano-jsx
Version:
SSR first, lightweight 1kB JSX library.
27 lines • 907 B
TypeScript
export declare class Store<S = any> {
private _state;
private _prevState;
private _listeners;
private _storage;
private _id;
/**
* Create your own Store.
* @param defaultState Pass the initial State.
* @param name The name of the Store (only required if you persist the state in localStorage or sessionStorage).
* @param storage Pass 'memory', 'local' or 'session'.
*/
constructor(defaultState: Object, name?: string, storage?: 'memory' | 'local' | 'session');
private persist;
/** Clears the state of the whole store. */
clear(): void;
setState(newState: S): void;
set state(newState: S);
get state(): S;
use(): {
readonly state: S;
setState: (newState: S) => void;
subscribe: (fnc: (newState: S, prevState: S) => void) => void;
cancel: () => void;
};
}
//# sourceMappingURL=store.d.ts.map