如何在javascript中阻止asnchronous调用

时间:2016-07-26 11:23:10

标签: javascript asynchronous

我有以下代码:

if (!project) {
        let pk_map =  this.backend.get_pk_map ()
        let pk = false
        if (pk_map.hasOwnProperty (path)) {
          pk =  pk_map[path]
        }
        const _this  = this
        if (!pk) {
          _this.network.getPackages (false , function (data){ 
              //here i want to block as I need pk for next call
              //  I cant do project =  this.network.getProject(data.pk) here
              // as I have further code too
               pk =  data.pk
           })
        }

        project =  this.network.getProject(pk) // Need the Pk here
 }

我想在_this.network.getPackages阻止异步调用。我怎么能这样做?

0 个答案:

没有答案