import {Action, Middleware} from "redux"; import {Effect, Pattern} from "./effects"; export {Effect, Pattern}; /** * Annotate return type of generators with `SagaIterator` to get strict * type-checking of yielded effects. */ export type SagaIterator = IterableIterator; type Saga0 = () => Iterator; type Saga1 = (arg1: T1) => Iterator; type Saga2 = (arg1: T1, arg2: T2) => Iterator; type Saga3 = (arg1: T1, arg2: T2, arg3: T3) => Iterator; type Saga4 = (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Iterator; type Saga5 = (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Iterator; type Saga6Rest = (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]) => Iterator; export interface Monitor { effectTriggered?(desc: { effectId: number; parentEffectId: number; label?: string; root?: boolean; effect: Effect; }): void; effectResolved?(effectId: number, res: any): void; effectRejected?(effectId: number, err: any): void; effectCancelled?(effectId: number): void; actionDispatched?(action: A): void; } export interface SagaMiddleware extends Middleware { run(saga: Saga0): Task; run(saga: Saga1, arg1: T1): Task; run(saga: Saga2, arg1: T1, arg2: T2): Task; run(saga: Saga3, arg1: T1, arg2: T2, arg3: T3): Task; run(saga: Saga4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): Task; run(saga: Saga5, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): Task; run(saga: Saga6Rest, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]): Task; setContext(props: Partial): void; } export type Logger = (level: string, ...args: any[]) => void; export type Emit = (input: T) => void; export interface SagaMiddlewareOptions { context?: C; sagaMonitor?: Monitor; logger?: Logger; onError?(error: Error): void; emitter?(emit: Emit): Emit; } export default function sagaMiddlewareFactory( options?: SagaMiddlewareOptions, ): SagaMiddleware; type Unsubscribe = () => void; type Subscribe = (cb: (input: T | END) => void) => Unsubscribe; export interface RunSagaOptions { context?: object; subscribe?: Subscribe; dispatch?(input: A): any; getState?(): S; sagaMonitor?: Monitor; logger?: Logger; onError?(error: Error): void; } export function runSaga( storeInterface: RunSagaOptions, saga: Saga0): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga1, arg1: T1): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga2, arg1: T1, arg2: T2): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga3, arg1: T1, arg2: T2, arg3: T3): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga5, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): Task; export function runSaga( storeInterface: RunSagaOptions, saga: Saga6Rest, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]): Task; /** * @deprecated */ export function runSaga(iterator: Iterator, options: RunSagaOptions): Task; export const CANCEL: string; export type END = {type: '@@redux-saga/CHANNEL_END'}; export const END: END; export type Predicate = (arg: T) => boolean; export interface Task { isRunning(): boolean; isCancelled(): boolean; result(): any | undefined; result(): T | undefined; error(): any | undefined; done: Promise; cancel(): void; setContext(props: Partial): void; } export interface Buffer { isEmpty(): boolean; put(message: T): void; take(): T | undefined; flush(): void; } export interface Channel { take(cb: (message: T | END) => void): void; put(message: T | END): void; flush(): void; close(): void; } export function channel(buffer?: Buffer): Channel; export function eventChannel(subscribe: Subscribe, buffer?: Buffer, matcher?: Predicate): Channel; export const buffers: { none(): Buffer; fixed(limit?: number): Buffer; dropping(limit?: number): Buffer; sliding(limit?: number): Buffer; expanding(limit?: number): Buffer; }; export function delay(ms: number): Promise; export function delay(ms: number, val: T): Promise; import * as effects from './effects'; import * as utils from './utils'; export {effects, utils}; type HelperFunc0 = (action: A) => any; type HelperFunc1 = (arg1: T1, action: A) => any; type HelperFunc2 = (arg1: T1, arg2: T2, action: A) => any; type HelperFunc3 = (arg1: T1, arg2: T2, arg3: T3, action: A) => any; type HelperFunc4 = (arg1: T1, arg2: T2, arg3: T3, arg4: T4, action: A) => any; type HelperFunc5 = (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, action: A) => any; type HelperFunc6Rest = ( arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, arg7: any, ...rest: any[]) => any; /** * @deprecated */ export function takeEvery( pattern: Pattern, worker: HelperFunc0): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc1, arg1: T1): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc2, arg1: T1, arg2: T2): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc3, arg1: T1, arg2: T2, arg3: T3): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc5, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): SagaIterator; export function takeEvery( pattern: Pattern, worker: HelperFunc6Rest, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc0): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc1, arg1: T1): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc2, arg1: T1, arg2: T2): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc3, arg1: T1, arg2: T2, arg3: T3): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc5, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): SagaIterator; export function takeEvery( channel: Channel, worker: HelperFunc6Rest, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]): SagaIterator; /** * @deprecated */ export const takeLatest: typeof takeEvery; /** * @deprecated */ export function throttle( ms: number, pattern: Pattern, worker: HelperFunc0): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc1, arg1: T1): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc2, arg1: T1, arg2: T2): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc3, arg1: T1, arg2: T2, arg3: T3): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc4, arg1: T1, arg2: T2, arg3: T3, arg4: T4): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc5, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): SagaIterator; export function throttle( ms: number, pattern: Pattern, worker: HelperFunc6Rest, arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, ...rest: any[]): SagaIterator;