Skip to content

Instantly share code, notes, and snippets.

@bjouhier
Forked from glennblock/fibers.js
Last active December 30, 2015 08:29
Show Gist options
  • Save bjouhier/7803022 to your computer and use it in GitHub Desktop.
Save bjouhier/7803022 to your computer and use it in GitHub Desktop.
//fibers
function markComplete(postedItems, completionCallback) {
var errors = [];
var getItemToUpdate = function(item) {
var fiber = Fiber.current;
process.nextTick(function() {
client.queryEntity('tasks', 'partition1', item, function(err, task) {
fiber.run(task);
});
});
return Fiber.yield();
};
Fiber(function() {
postedItems.forEach(function(item) {
task = getItemToUpdate(item);
console.log(task);
});
completionCallback(undefined);
}).run();
}
@glennblock
Copy link

Aaah, i saw I could pass to run but didn't realize I can return the yield and it would flow through. OK on the try/catch.

Thanks!
Glenn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment