Skip to content

Instantly share code, notes, and snippets.

@dperussina
Created October 10, 2017 00:35
Show Gist options
  • Save dperussina/353fdc0d5da8a3903cd7edcaabc20d53 to your computer and use it in GitHub Desktop.
Save dperussina/353fdc0d5da8a3903cd7edcaabc20d53 to your computer and use it in GitHub Desktop.
var orders = [1243, 567, 98978]
var orderCount = orders.length - 1;
var cache = [];
// This version will apply duplicate messages
orders.forEach(function(element, iteration, array) {
// Gets All messages for each Child
cache = GetAllMessages(orders[itteration]);
// Applies messages to all orders every iteration
ApplyMessagesToOrders(cache);
});
var orders = [1243, 567, 98978]
var orderCount = orders.length - 1;
var cache = [];
// This version will concat all messages
// Then on the last iteration will apply 1 instance of each
// message to each order
orders.forEach(function(element, iteration, array) {
// Gets all messages for each Child
// Concats all messages to a single grouping
cache.concat(getOrderMessages(iteration));
// Only applies messages to Each order on the last iteration
// Instead of each iteration
if(itteration == orderCount){
ApplyMessagesToOrders(cache);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment