javascript - Node.js meteor.js fibers and loop -
okay learning fibers , dont know how implement "waiting end of loop inside fiber"
now have code works without problem.
if (meteor.isserver) { function checkifiownthisitem(callback) { settimeout(function() { callback("this callback"); }, 500); } var f = fiber(function() { var fiber = fiber.current; checkifiownthisitem(function(str) { fiber.run(str); }); str = fiber.yield(); console.log(str); }); f.run(); }
and need replace settimeout ...for...
_.each(mybank.items,function(loopitem,key,list){ if (loopitem.itemid == item.itemid) { ownitem = true; countofowniteminbank = parseint(loopitem.number); } });
the whole point first check if own item (own item true) , can whatever hell want need sure ownitem true
it sounds starting memories fibers/threads in desktop programming , trying map exact equivalence. remember world. don't think way. fibers more not waiting around answer come time.
i bet if take smaller steps, think less, , html/js want, come here when hit stopping block, make progress.
ownership of items, example, commonly expressed field in document, ownerid, matching current userid
Comments
Post a Comment