import { takeEvery } from '@zaibot/fsa-saga'; import { fork } from 'redux-saga/effects'; import { IResourceDescriptor } from '.'; import { applyMiddlewares, IMiddleware } from '../utils'; function* noop(param: any): IterableIterator { // Nothing } export function makeSaga(descriptor: IResourceDescriptor, ...middlewares: Array>) { const actions = [ ...descriptor.actions.all, ]; const f = applyMiddlewares(...middlewares); return function* internal(): any { yield takeEvery(actions, function*(action) { yield fork(() => f({ action, descriptor }, noop)); }); }; }