Long computations on Meteor

血红的双手。 提交于 2019-12-02 02:51:55

Meteor uses Fibers which behave a little different than usual Node.js code. I believe there's no need to yield manually. Instead, you may want to use this.ublock() method on the server side – see this awesome article that explains it in details.

If you're doing something really heavy on the client side (like calculating Mandelbrot set), split the execution with defers:

_.defer(function() {
  doSomethingQuiteLong();
  _.defer(function() {
    doSomethingQuiteLongAgain();
    ...
  });
});

Here is something interesting:

"In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application." -http://docs.meteor.com/#structuringyourapp

It seems there is no need to worry about the node.js limitation. But what does this mean then?

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