Created
July 18, 2015 07:08
-
-
Save chrisabrams/e60c7c591aca25238cb4 to your computer and use it in GitHub Desktop.
Async Example
This file contains hidden or 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
// 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