Meteor wrapAsync syntax

后端 未结 1 1136
走了就别回头了
走了就别回头了 2020-12-11 06:54

How do I use the Meteor wrapAsync?

Below is what I am trying to do

if (tempTreatment.groupId === undefined) {
         


        
相关标签:
1条回答
  • 2020-12-11 07:19

    Meteor.wrapAsync is a server-side API designed to wrap Node.js asynchronous functions requiring a callback as last argument, to make them appear synchronous through the use of Futures, a Fibers sub-library. (more on this here : https://www.discovermeteor.com/blog/wrapping-npm-packages/)

    It is not intended to be used client-side to turn asynchronous Meteor.call into a synchronous call because on the browser, Remote Method Invokation calls are ALWAYS asynchronous.

    Long story short, you simply cannot achieve what you're trying to do, you have to use callbacks and nest your second method call inside the success callback of your first method call.

    0 讨论(0)
提交回复
热议问题