Skip to content

Instantly share code, notes, and snippets.

@jquense
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquense/0d35da1e457be6952f41 to your computer and use it in GitHub Desktop.
Save jquense/0d35da1e457be6952f41 to your computer and use it in GitHub Desktop.
Fluxy errors
var loginStore = Store({
init(dispatcher){
var self = this;
dispatcher.register(function(action, payload){
if( action === 'LOGIN')
self.login()
})
},
login(){
api.login()
.catch(function(err){
this.state.error = err
})
.finally(function(){
this.emitChange()
})
}
})
var alerts = Store({
init(dispatcher){
var self = this;
dispatcher.register(function(action, payload){
if( action === 'LOGIN')
this.login()
})
},
login(){
this.waitFor('loginStore')
if (loginStore.state.error) {
this.state.authError = loginStore.state.error
this.emitChange()
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment