import { Epic } from "redux-observable"; import { AsyncActionCreator, Action } from "redux-toolbelt"; import { Observable } from "rxjs"; /** * Creates an epic that handles actions created makeAsyncActionCreator. * The epic listens to the request action and dispatches success and failure actions. * * @template A The type of actions the function can potentially respond to * * @template S The type of state this function might use * * @template P The type of data the promise might return * * @param {AsyncActionCreator} actionCreator * An action creator made with makeAsyncActionCreator * * @param {makeAsyncEpic.AsyncFn} asyncFn * An async function that can get 4 paramters and returns a promise * `(payload, type, meta, state$) => promise` * - payload. The action payload * - type. The action type * - meta. The action meta * - state$. An observable containing the current state * * @param {makeAsyncEpic.Options} [options] * An object with options: * - `ignoreOlderParallelResolves`. If several promises are made before any * of them resolves, you can choose to ignore older resolves and only receive the last one by passing true to * this option. * * @returns {Epic} Async Epic */ export declare function makeAsyncEpic( actionCreator: AsyncActionCreator, asyncFn: makeAsyncEpic.AsyncFn, options?: makeAsyncEpic.Options ): Epic export namespace makeAsyncEpic { export interface Options { ignoreOlderParallelResolves?: boolean; cancelPreviousFunctionCalls?: boolean; } export type AsyncFn = ( payload?: A['payload'], type?: A['type'], meta?: A['meta'], state$?: Observable ) => Promise } export default makeAsyncEpic;
} export default makeAsyncEpic;