Future.wait() can't wait without a fiber (while waiting on another future in Meteor.method)

不想你离开。 提交于 2019-12-01 04:07:42

Wrap your callback into Meteor.bindEnvironment, example:

fs.readdir(dir, Meteor.bindEnvironment(function (err, res) {
    if (err) future.throw(err);
    future.return(res);
}, function (err) { console.log("couldn't wrap the callback"); });

Meteor.bindEnvironment does a lot of things and one of them is to make sure callback is running in a Fiber.

Another thing that could be helpful is var funcSync = Meteor._wrapAsync(func) which utilizes futures and allows use to call a function in synchronous style (but it is still async).

Watch these videos on evented mind if you want to know more: https://www.eventedmind.com/posts/meteor-dynamic-scoping-with-environment-variables https://www.eventedmind.com/posts/meteor-what-is-meteor-bindenvironment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!