Just an idea, to practice after reading about redux async actions and middleware
the important part is this function
let INTERVAL = 50
let runTimer = () => {
return (dispatch, getState) => {
dispatch(start())
let timer = () => {
if (getState().running) {
dispatch(time())
setTimeout(timer, INTERVAL)
}
}
timer()
}
}
its about how thunk lets us dispatch several async actions from inside one action. Using app state to stop dispatching actions is just one example, it could also be a promise that has resolved, or any call out to async functions, that has finished