Skip to content

Instantly share code, notes, and snippets.

@Kyle-Muir
Created February 29, 2016 22:39
Show Gist options
  • Save Kyle-Muir/a2cac3c4f13c6919a5e3 to your computer and use it in GitHub Desktop.
Save Kyle-Muir/a2cac3c4f13c6919a5e3 to your computer and use it in GitHub Desktop.
AngularJS\Typescript - Synchronously execute promises
private synchronouslyExecuteCommands = (commands: Array<IProductModificationCommand>, product: Model.Product): ng.IPromise<any> => {
var commandPromises = this.$q.when();
_.each(commands, (command: IProductModificationCommand) => {
commandPromises = commandPromises.then(() => {
return command.execute(product);
});
});
return commandPromises;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment