import { type Dispatch } from "react"; import { type CallEffect, type SelectEffect } from "redux-saga/effects"; /** * react-state-factory use actions in * { type: string, payload: any } format */ export type ActionType = T extends { type: infer U; payload: infer P; } ? { type: U; payload: P; } : never; /** * Labes use for automatic create labels by user created ActionsMaper type * which looks like * ```ts * export type ActionsMap = * | { type: "FOO_ACTION", payload: string } * | { type: "ADD_ITEM", payload: Item } * | { type: "REMOVE_ITEM", payload: ItemId } * * export const label:Labels = {} * ``` */ export type Labels> = { [K in AM['type']]: K; }; export type TypedActionMap, EM extends Labels> = { [T in keyof EM]: (payload: Extract, { type: T; }>["payload"]) => void; }; export declare function typedActionMapFactory>(keys: Labels, dispatch: Dispatch): TypedActionMap>; export declare function typedPutActionMapFactory>(labels: Labels): TypedActionMap>; export type UseFactoryReturn = [state: ST, put: Put]; export declare const useStateFactory: >(reducer: (st: ST, action: AM) => ST, initialState: ST, labels: PT) => UseFactoryReturn>; export type GeneratorSaga = () => Generator | SelectEffect, void, ST>; export declare const useSagaFactory: >(reducer: (st: ST, action: AM) => ST, initialState: ST, labels: PT, saga: GeneratorSaga) => UseFactoryReturn>;