Last active
August 29, 2015 14:16
-
-
Save jquense/0d35da1e457be6952f41 to your computer and use it in GitHub Desktop.
Fluxy errors
This file contains 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
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