Skip to content

Instantly share code, notes, and snippets.

@cjbell
Created February 1, 2015 22:42
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 cjbell/754eb098714cdb41f186 to your computer and use it in GitHub Desktop.
Save cjbell/754eb098714cdb41f186 to your computer and use it in GitHub Desktop.
Example of remote Flux request
var API = {
get: function() {
return new Promise(function() {
// ... some code to get remotely
});
}
}
var UserAPI = {
getById: function(id) {
return API.get('/users/' + id);
}
}
var UserActionCreators = {
requestUserById: function(userId) {
UserAPI.getById(userId)
.then(function(data) {
UserServerActionCreators.handleUserSuccess(data);
})
.catch(function() {
// Notify of error
UserServerActionCreators.handleUserError(data);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment