reactotron
reactotron copied to clipboard
Sagas trigger with takeLeading redux-sagas effect are not logged in reactotron.
Sagas trigger with takeLeading redux-sagas effect are not logged in reactotron. Only takeLatest
and takeEvery
are working
Implementing takeLeading
manually, using fork
passing a saga with while(true)
with a take
action inside, is not working too. Example:
function* mySaga() {
while(true) {
yield take(SOME_ACTION);
yield call(anotherSaga);
}
}
export function* rootSaga() {
yield all([
fork(mySaga)
])
}
I don't know if this is really a Reactotron issue, or a reactotron-redux-saga issue.
This issue happens because takeLeading
uses call
to block waiting for the result of anotherSaga
. The function call
does not create a new Task
to run anotherSaga
, like fork
does. Since takeLatest
uses fork
to run the new generator as non-blocking, a new Task
is created and everything works fine.
The reactotron-redux-saga
's sagaMonitor waits for the resolve
state of Task's Promise
to send data to Reactotron.
https://github.com/infinitered/reactotron-redux-saga/blob/master/src/sagaMonitor.ts#L171-L177
I wrote a new takeLeading
on my project that use fork
to create a new Task
, and join
to block waiting for the result of that task. I don't know if this can cause some performance issues to the project, but now Reactotron is logging saga effects. Maybe I use just for debugging.
const takeLeading = (patternOrChannel, saga, ...args) => fork(function*() {
while (true) {
const action = yield take(patternOrChannel);
const task = yield fork(saga, ...args.concat(action));
yield join(task);
}
})