Skip to content

Instantly share code, notes, and snippets.

@chrisabrams
Created July 18, 2015 07:08
Show Gist options
  • Save chrisabrams/e60c7c591aca25238cb4 to your computer and use it in GitHub Desktop.
Save chrisabrams/e60c7c591aca25238cb4 to your computer and use it in GitHub Desktop.
Async Example
// Declarations
function getUser(id, cb) {
api.get('http://url/user/' + id, function(data) {
cb(data)
})
}
function getUserProfile(id, cb) {
api.get('http://url/user/' + id + '/profile', function(profile) {
cb(profile)
})
}
// Implementation
getUser('23', function(user) {
getUserProfile(user.id, function(profile) {
// do something here
var view = new View({
model: new Model(profile)
})
view.render()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment