Skip to content

Instantly share code, notes, and snippets.

@tychota
Created August 8, 2016 00:29
Show Gist options
  • Save tychota/afdfcde2e6440d16cd307d6401c8c1c3 to your computer and use it in GitHub Desktop.
Save tychota/afdfcde2e6440d16cd307d6401c8c1c3 to your computer and use it in GitHub Desktop.
Redux-Saga Flowtype (totally rough and unfinished)
/* eslint-disable */
declare type $npm$ReduxSaga$IOEffect = {
'@@redux-saga/IO': true,
}
declare type $npm$ReduxSaga$TakeEffect = $npm$ReduxSaga$IOEffect & {
TAKE: string,
};
declare type $npm$ReduxSaga$PutEffect<T> = $npm$ReduxSaga$IOEffect & {
PUT: T,
};
declare type $npm$ReduxSaga$CallEffect<U> = $npm$ReduxSaga$IOEffect & {
CALL: {
context: ?mixed,
fn: (...args: Array<mixed>) => Promise<U>,
args: Array<any>
},
};
declare type $npm$ReduxSaga$Effect = $npm$ReduxSaga$TakeEffect
| $npm$ReduxSaga$PutEffect
| $npm$ReduxSaga$CallEffect;
declare module 'redux-saga/effects' {
declare type Pattern = string | (action: Object) => boolean;
declare module.exports: {
take: (pattern: Pattern) => $npm$ReduxSaga$TakeEffect,
put: <T>(action: T) => $npm$ReduxSaga$PutEffect<T>,
call: <T, U>(fn: (...args: Array<any>) => Promise<U>, ...args: Array<any>) => $npm$ReduxSaga$CallEffect<U>, // [context, fn]
apply: () => any, // [context, fn]
cps: () => any, // [context, fn]
fork: () => any, // [context, fn]
join: (task: any) => any,
cancel: (task: any) => any,
select: (selector: any, ...args: Array<any>) => any,
race: (effects: any) => any,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment