Skip to content

Instantly share code, notes, and snippets.

@drewrawitz
Created August 20, 2016 04:03
Show Gist options
  • Save drewrawitz/231ccc56bd442dae0ce009d23cd28373 to your computer and use it in GitHub Desktop.
Save drewrawitz/231ccc56bd442dae0ce009d23cd28373 to your computer and use it in GitHub Desktop.
export const updateAlert = (alert, message) => {
return {
type: 'UPDATE_ALERT',
alert,
message
}
}
export const updateAlertThenDelete = (alert, message) => {
return function (dispatch) {
return dispatch(
updateAlert(alert, message).then(() => {
console.log('done');
})
)
}
}
this.props.updateAlertThenDelete('error', ERROR_MESSAGE)
@drewrawitz
Copy link
Author

drewrawitz commented Aug 20, 2016

@ddsol, you're right. I think I was overthinking this. I don't even need a callback in this instance.. all I need to do is:

  waitTurn() {
    const ERROR_MESSAGE = 'Please wait your turn.';

    this.props.updateAlert('error', ERROR_MESSAGE)
    setTimeout(() => {
      console.log('remove alert code here');
    }, 5000)
  }

Thank you for explaining everything to me, it's now starting to make sense. I appreciate it!

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