UNPKG

nucleux

Version:

Simple, atomic hub for all your React application's state management needs. No providers, no boilerplate, just state that works.

21 lines (20 loc) 751 B
import { AtomInterface } from './Atom'; type StoreProxyAtoms<S> = { readonly [K in keyof S as S[K] extends AtomInterface<any> ? K : never]: S[K] extends AtomInterface<infer T> ? T : never; }; type AnyFunction = (...args: any[]) => any; type StoreProxyMethods<S> = { readonly [K in keyof S as S[K] extends AnyFunction ? K : never]: S[K]; }; interface StoreInterface { destroy?: () => void; } type StoreProxy<S> = StoreProxyAtoms<S> & StoreProxyMethods<S>; interface StoreConstructable<T> { new (...args: unknown[]): T & StoreInterface; } type StoreDefinition<S> = { storeId: string; storeClass: StoreConstructable<S>; }; export { AnyFunction, StoreConstructable, StoreDefinition, StoreInterface, StoreProxy, StoreProxyAtoms, };