Long computations on Meteor

前端 未结 2 1248
南旧
南旧 2021-01-22 07:48

I learned that in Node.js you yield in between long computations to prevent the server from blocking. How do you achieve this on Meteor? Are there techniques for al

2条回答
  •  清歌不尽
    2021-01-22 07:59

    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();
        ...
      });
    });
    

提交回复
热议问题