Skip to content

Instantly share code, notes, and snippets.

@jsheely
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsheely/ff9569a47571e161bd6a to your computer and use it in GitHub Desktop.
Save jsheely/ff9569a47571e161bd6a to your computer and use it in GitHub Desktop.
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