-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generator with 'takeLatest' - is canceling and debouncing possible? #3
Comments
I'll try to release a new version these days. Funny enough I hit the same problem. I just needed |
I just stumbled upon this project due to your great article and this was the first thing that came to my mind when taking a glance at your README. |
Yep, that's definitely a valid use case. I'm going to add something which will work like |
Ok, just released machine.fetchTodos.latest(); This will kill a previous call which is still in progress. However, I have to make a note here. Let's see the following redux-saga code: function test (n) {
return {
type: 'TEST',
n
};
}
store.runSaga(function * () {
yield takeLatest('TEST', function * ({ n }) {
console.log(n);
setTimeout(() => console.log('you can not stop me'), 2000);
console.log('promise: ' + (yield call(a, n)));
});
});
store.runSaga(function *() {
yield put(test(1));
yield put(test(2));
});
/*
1 <-- immediately
2 <-- immediately
promise 2 <-- a second later
you can not stop me <-- two seconds later
you can not stop me <-- two seconds later
*/ So we have a saga that waits for an action. Once this action comes we do something (the first That new version of Stent support |
You showed an example with generators:
If I would perform
machine.fetchTodos()
twice while the async call is still ongoing, the second one is simply discarded.The text was updated successfully, but these errors were encountered: