Last active
August 29, 2015 14:19
-
-
Save jsheely/ff9569a47571e161bd6a to your computer and use it in GitHub Desktop.
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
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