mvp of request effect

This commit is contained in:
Daniel Ternyak 2018-02-08 17:58:43 -06:00
parent eaa9ac392c
commit 35498bf7ab
No known key found for this signature in database
GPG Key ID: DF212D2DC5D0E245
1 changed files with 14 additions and 0 deletions

14
common/sagas/helpers.ts Normal file
View File

@ -0,0 +1,14 @@
import { delay as RDelay, SagaIterator } from 'redux-saga';
import { apply, all, call } from 'redux-saga/effects';
type Func1<T1> = (arg1: T1) => any;
export function* request<T1>(
context: any,
fn: Func1<T1>,
args: [T1],
delay: number = 500
): SagaIterator {
const [result] = yield all([apply(context, fn, args), call(RDelay, delay)]);
return result;
}