javascript - how does meteor handle async calls -
starting working on new meteor app, have done node.js projects callbacks or promises handle async code going through meteor tutorials; async methods have no callbacks or promises. how handled? example code tutorial:
var party = parties.findone(partyid); if (!party) throw new meteor.error(404, "no such party"); if (party.owner !== this.userid) throw new meteor.error(404, "no such party"); if (party.public) throw new meteor.error(400, "that party public. no need invite people.");
how can fetch db , perform operations on party
meteor uses magical abstraction coroutines called fiber. works same async/await in many other languages. desribe possible: there callbacks underneath, don't need handle them hand.
https://github.com/laverdet/node-fibers
/edit
there great article on meteorhacks describing how fibers work: https://meteorhacks.com/fibers-eventloop-and-meteor
Comments
Post a Comment