diff --git a/common/sagas/helpers.ts b/common/sagas/helpers.ts new file mode 100644 index 00000000..6493397b --- /dev/null +++ b/common/sagas/helpers.ts @@ -0,0 +1,14 @@ +import { delay as RDelay, SagaIterator } from 'redux-saga'; +import { apply, all, call } from 'redux-saga/effects'; + +type Func1 = (arg1: T1) => any; + +export function* request( + context: any, + fn: Func1, + args: [T1], + delay: number = 500 +): SagaIterator { + const [result] = yield all([apply(context, fn, args), call(RDelay, delay)]); + return result; +}