export function *incrementSaga() {
let counter;
while (true) {
yield take('COUNT_UP');
counter = 1;
while (true) {
const { inc } = yield race({
inc: take('COUNT_UP'),
timeout: call(delay, 5000),
});
if (inc) {
counter++;
}
else {
yield put({ type: 'USER_COUNTED', value: counter });
break;
}
}
}
}
More here