core-native
Version:
A lightweight framework based on React Native + Redux + Redux Saga, in strict TypeScript.
34 lines (33 loc) • 1.59 kB
TypeScript
import { Action } from "./reducer";
declare type DeferLiteralArrayCheck<T> = T extends Array<string | number | boolean | null | undefined> ? T : never;
export declare function useLoadingStatus(identifier?: string): boolean;
/**
* Action parameters must be of primitive types, so that the dependency check can work well.
* No need add dispatch to dep list, because it is always fixed.
*/
export declare function useAction<P extends Array<string | number | boolean | null | undefined>>(actionCreator: (...args: P) => Action<P>, ...deps: P): () => void;
/**
* For actions like:
* *foo(a: number, b: string, c: boolean): SagaGenerator {..}
*
* useUnaryAction(foo, 100, "") will return:
* (c: boolean) => void;
*/
export declare function useUnaryAction<P extends any[], U>(actionCreator: (...args: [...P, U]) => Action<[...DeferLiteralArrayCheck<P>, U]>, ...deps: P): (arg: U) => void;
/**
* For actions like:
* *foo(a: number, b: string, c: boolean): SagaGenerator {..}
*
* useBinaryAction(foo, 100) will return:
* (b: string, c: boolean) => void;
*/
export declare function useBinaryAction<P extends any[], U, K>(actionCreator: (...args: [...P, U, K]) => Action<[...DeferLiteralArrayCheck<P>, U, K]>, ...deps: P): (arg1: U, arg2: K) => void;
/**
* For actions like:
* *foo(data: {key: number}): SagaGenerator {..}
*
* useModuleObjectAction(foo, "key") will return:
* (objectValue: number) => void;
*/
export declare function useObjectKeyAction<T extends object, K extends keyof T>(actionCreator: (arg: T) => Action<[T]>, objectKey: K): (objectValue: T[K]) => void;
export {};