Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created November 16, 2016 00:53
Show Gist options
  • Save dariocravero/06d3b3170c2537cd890b6fe27a4c6f12 to your computer and use it in GitHub Desktop.
Save dariocravero/06d3b3170c2537cd890b6fe27a4c6f12 to your computer and use it in GitHub Desktop.
const TIMEOUT = 100
const click = () => (dispatch, getState) => {
setTimeout(dispatch({
type: 'CLICK'
}, TIMEOUT)
}
const Button = props => {
const onClick = () => props.dispatch(click())
return <button onClick={} />
}
const click = () => ({
type: 'CLICK'
})
const TIMEOUT = 100
const Button = props => {
const onClick = () => setTimeout(props.dispatch(click(), TIMEOUT)
return <button onClick={onClick} />
}
@dariocravero
Copy link
Author

In reply to Q9 How can I dispatch a Redux action w/a timeout? #reduxbook

https://twitter.com/dariocravero/status/798690619157778433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment