Created
March 1, 2020 17:19
-
-
Save Godefroy/de8f8e5cb2d9e5a996ef7d2147520b23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function incrementAsync(n) { | |
return async (dispatch, getState) => { | |
console.log('initial count', getState().counter.count) | |
dispatch({ type: 'COUNTER_COUNTING', counting: true }) | |
for (let i = 1; i <= n; i++) { | |
dispatch({ type: 'COUNTER_INCREMENT', n: 1 }) | |
await new Promise(resolve => setTimeout(resolve, 500)) | |
} | |
dispatch({ type: 'COUNTER_COUNTING', counting: false }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment