UNPKG

@sandstack/neuron

Version:

Neuron is a lightweight framework agnostic global state manager for Javascript apps, with React support

23 lines (22 loc) 968 B
import { IModule, NeuronOptions, ClientName, ClientMethods, NeuronKey } from "../core"; import { DynamicNeuronHook } from "./useNeuron"; import { Actions, StateOrSlice } from "./useSubscriber"; export declare class NeuronClient implements INeuronClient { neuron: ReactClientNeuron; useNeuron: <T = unknown>(neuronKey: NeuronKey) => [T, (newState: T | ((prev: T) => T)) => void]; readonly name?: ClientName; readonly client: ClientMethods; constructor(options?: ClientOptions); } interface INeuronClient { readonly name?: Readonly<ClientName>; readonly client: ClientMethods; readonly neuron: ReactClientNeuron; readonly useNeuron: DynamicNeuronHook; } export interface ClientOptions { name?: ClientName; modules?: IModule[]; } export type ReactClientNeuron = <T, A = unknown>(initialState: T, options?: NeuronOptions<T, A>) => <S>(slice?: ((state: T) => S) | undefined) => [StateOrSlice<S, T>, Actions<T, S, A>]; export {};