Skip to content

Instantly share code, notes, and snippets.

@kenelliott
Created April 11, 2016 13:59
Show Gist options
  • Save kenelliott/5d2a4dd445f7459b7ff3afe072d51a5d to your computer and use it in GitHub Desktop.
Save kenelliott/5d2a4dd445f7459b7ff3afe072d51a5d to your computer and use it in GitHub Desktop.
// don't make functions within a loop
model.get('things').then(things => {
things.forEach(thing => {
thing.get('attachment').then(attachment => {
thing.set('foo', true);
attachment.set('bar', true);
});
})
});
// attempted solution
model.get('things').then(things => {
things.forEach(thing => {
// how do I pass attachment without making a function?
thing.get('attachment').then(attachmentFunction(thing));
})
});
var attachmentFunction = function(attachment, thing) {
thing.set('foo', true);
attachment.set('bar', true);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment