timeout - Redux-saga : detect a time-consuming async task -


i trying detect when task takes long time using redux-saga. someheavyasyncfunc task varying time consumption, few ms seconds. want trigger action when takes more amount of time, show loader.

however don't want race delay, want trigger loading action if necessary don't want cancel action if long.

here excerpt of idea:

    const timeout = yield fork(function* () {       yield call(delay, 300);       yield put(ispending());     });     // in parallel run computation     // cancel timeout after computation done     const task = yield fork(function* () {       const res = yield call(someheavyasyncfunc);       yield cancel(timeout);       yield put(success());     }); 

the timeout run in background. if over, put action show loader. timeout cancelled when task done, loader not shown if task fast.

however, not seem work. pending action triggered if action more 300ms in exemple. however, not triggered delay on later, loader show late.

does have working example on ? maybe saga wrong ask undoable using redux (due reducer computation time) ?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -