Created
November 16, 2016 00:53
-
-
Save dariocravero/06d3b3170c2537cd890b6fe27a4c6f12 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
const TIMEOUT = 100 | |
const click = () => (dispatch, getState) => { | |
setTimeout(dispatch({ | |
type: 'CLICK' | |
}, TIMEOUT) | |
} | |
const Button = props => { | |
const onClick = () => props.dispatch(click()) | |
return <button onClick={} /> | |
} |
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
const click = () => ({ | |
type: 'CLICK' | |
}) | |
const TIMEOUT = 100 | |
const Button = props => { | |
const onClick = () => setTimeout(props.dispatch(click(), TIMEOUT) | |
return <button onClick={onClick} /> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In reply to Q9 How can I dispatch a Redux action w/a timeout? #reduxbook
https://twitter.com/dariocravero/status/798690619157778433