redux-saga: Sagas started with runSaga can't take actions from Saga started with the middleware
Let’s say I have 2 sagas:
- simple api saga that was provided to middleware:
function* apiSaga(getState){
while(true){
const action = yield take('API')
const { result, error } = yield call(requestApiService, action)
const [reqType, successType, failType ] = action.types
yield put({ type: reqType, action })
if(error) {
yield put({ type: failType, error })
} else {
yield put({ type: successType, result})
}
}
}
- another saga, that I want to call with
runSaga
method:
function* routeResolveSaga(getState){
yield put({ type: 'API', ..... types: ['ACTION_REQUEST', 'ACTION_SUCCESS', 'ACTION_FAIL'] })
yield take(['ACTION_SUCCESS', 'ACTION_FAIL'])
}
When I call
runSaga(function*(getState){
yield call(routeResolveSaga, getState)
}(store.getState), storeIO(store))
apiSaga
takes API
action, after request is puts new action ACTION_SUCCESS
or ACTION_FAIL
, routeResolveSaga
is waiting to take it, but nothing happens.
Maybe I have missed something?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (7 by maintainers)
I just put together a minimal example - the kicker… it works as expected! I’ll keep investigating as to why it doesn’t work in my full react app.
In my full app if i don’t “fork” it works. I think i’ll just not fork.