Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var models = [{
name: 'Jonathan',
location: 'Earth'
}, {
name: 'Joe',
location: 'Mars'
}]
models.forEach(function(model) {
if (model.name) {
nameFormatter.format(model.name, function(err, result) {
model.name = result;
});
}
if (model.location) {
geocorder.geocode(model.location, function(err, result) {
model.location = result;
});
}
//Don't fire until async operations have updated the model.
model.save();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment