I am trying to call some function AFTER _.each is done... i am trying to do it with fibers. But if you show me how to do it with underscore.js AFTER method i will be happy as well.
For now i have this:
function doAsyncWork() {
var fiber = Fiber.current;
_.each(myInv.items,function(loopItem,key,list){
if (loopItem.itemId == item.shopId) {
ownItem = true;
countOfOwnItem = loopItem.number;
}
Fiber.yield();
});
}
Fiber(function() {
doAsyncWork();
}).run();
And i need to place somewhere fiber.run() as well or? But i dont know where.
Again i want to call some function lets say finished() WHEN THE EACH LOOP is done.