UNPKG

@freik/recoil-tools

Version:

Kevin Frei's Web utilities for Recoil

26 lines 1.97 kB
import { RecoilValueReadOnly, CallbackInterface, DefaultValue, RecoilState, SerializableParam, SetterOrUpdater } from 'recoil'; import { BoolState, KeyEventType } from '@freik/react-tools'; export type StatePair<T> = [T, SetterOrUpdater<T>]; export declare function kbTypingHook<T extends KeyEventType>(filterState: RecoilState<string>, updateTypedValue: (srch: string) => void): ({ set }: CallbackInterface) => (ev: T) => void; export declare function MakeSetSelector<T extends SerializableParam>(setOfObjsState: RecoilState<Set<T>>, key: string): (param: T) => RecoilState<boolean>; export declare function MakeSetState<T extends SerializableParam>(key: string): [RecoilState<Set<T>>, (param: T) => RecoilState<boolean>]; export declare function useBoolRecoilState(theAtom: RecoilState<boolean>): BoolState; export type AtomEffectParams<T> = { node: RecoilState<T>; trigger: 'get' | 'set'; setSelf: (newVal: T | DefaultValue | Promise<T | DefaultValue> | ((curVal: T | DefaultValue) => T | DefaultValue)) => void; resetSelf: () => void; onSet: (func: (newValue: T | DefaultValue, oldValue: T | DefaultValue) => void) => void; }; export declare function getAtomValuesEffect(): void; type KeyboardHookType<T extends KeyEventType> = (cbIntfc: CallbackInterface) => (ev: T) => void; export declare function keyboardHook<T extends KeyEventType>(filterState: RecoilState<string>): KeyboardHookType<T>; export type MyTransactionInterface = { get: <T>(recoilVal: RecoilState<T> | RecoilValueReadOnly<T>) => T; set: <T>(recoilVal: RecoilState<T>, valOrUpdater: ((currVal: T) => T) | T) => void; reset: <T>(recoilVal: RecoilState<T>) => void; }; type FnType<Args extends readonly unknown[], Return> = (...args: Args) => Return; export declare function useMyTransaction<Args extends readonly unknown[], Return>(fn: (ntrface: MyTransactionInterface) => FnType<Args, Return>): FnType<Args, Return>; export {}; //# sourceMappingURL=index.d.ts.map