当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bluebird.defer函数代码示例

本文整理汇总了TypeScript中bluebird.defer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defer函数的具体用法?TypeScript defer怎么用?TypeScript defer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了defer函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: show

export function show() {
    defer = Promise.defer();

    const templateArgs = {
        modeLabel: Strings.CLONE_REPOSITORY,
        Strings
    };

    const compiledTemplate = Mustache.render(template, templateArgs, {
        credentials: credentialsTemplate
    });
    const dialog = Dialogs.showModalDialogUsingTemplate(compiledTemplate);
    const $dialog = dialog.getElement();

    $cloneInput = $dialog.find("#git-clone-url");

    _attachEvents($dialog);

    dialog.done((buttonId) => {
        if (buttonId === "ok") {
            const cloneConfig = {
                remote: "origin",
                remoteUrl: $cloneInput.val()
            };
            RemoteCommon.collectValues(cloneConfig, $dialog);
            defer.resolve(cloneConfig);
        } else {
            defer.reject();
        }
    });

    return defer.promise;
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:33,代码来源:Clone.ts

示例2: show

export function show(_pullConfig) {
    defer = Promise.defer();
    pullConfig = _pullConfig;
    pullConfig.pull = true;
    RemoteCommon.collectInfo(pullConfig).then(_show);
    return defer.promise;
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:7,代码来源:Pull.ts

示例3: existsAsync

export function existsAsync(path: string): Promise<boolean>{
    var deferral = Promise.defer();
    fs.exists(path, (res) => {
        deferral.resolve(res);
    });
    return deferral.promise;
}
开发者ID:geeklearningio,项目名称:gl-swagger-generator,代码行数:7,代码来源:filesystem.ts

示例4: postString

 function postString(msg): PromiseLike<Typehinted> {
   const p = Promise.defer<Typehinted>();
   const wireMsg = `{"req": ${msg}, "callId": ${ensimeMessageCounter}}`
   callbackMap[ensimeMessageCounter++] = p
   log.debug("outgoing: " + wireMsg)
   netClient.send(wireMsg)
   return p.promise;
 }
开发者ID:hedefalk,项目名称:ensime-node,代码行数:8,代码来源:server-connection.ts

示例5: listen

 /**
  * Listen the restify server.
  * @override
  * @returns {Promise<void>}
  */
 public listen() {
   var deferred = Promise.defer<void>();
   this.adaptee.listen(this.options.port, (err) => {
     if (err) return deferred.reject(err);
     deferred.resolve();
   });
   return deferred.promise;
 }
开发者ID:himulawang,项目名称:island,代码行数:13,代码来源:restify-adapter.ts

示例6: backoff

function backoff(idx: number) {
    let timeout = BACKOFF[idx];
    let dfd = P.defer();
    log.info("Retrying request after:", timeout);
    setTimeout(() => {
        dfd.resolve(timeout);
    }, timeout);
    return dfd.promise;
}
开发者ID:gradecam,项目名称:nodejs-schoolnet-api,代码行数:9,代码来源:schoolnet.ts

示例7: readDirAsync

export function readDirAsync(path: string): Promise<string[]>{
    var deferral = Promise.defer();
    fs.readdir(path, (err, res) => {
        if(err){
            deferral.reject(err);
        } else {
            deferral.resolve(res);
        }
    });
    return deferral.promise;
}
开发者ID:geeklearningio,项目名称:gl-swagger-generator,代码行数:11,代码来源:filesystem.ts

示例8: getTempPath

const withTempFile = (filePath: string, bufferText: string) : PromiseLike<string> => {
    const tempFilePath = getTempPath(filePath);
    const p = Promise.defer<string>();
    fs.outputFile(tempFilePath, bufferText, (err) => {
        if (err)
            p.reject("error with file");
        else 
            p.resolve(tempFilePath);
    });
    return p.promise; 
} 
开发者ID:hedefalk,项目名称:ensime-node,代码行数:11,代码来源:server-api.ts

示例9: readAsync

export function readAsync(path: string): Promise<string>{
    var deferral = Promise.defer();
    fs.readFile(path, "utf-8", (err, res) => {
        if(err){
            deferral.reject(err);
        } else {
            deferral.resolve(res);
        }
    });
    return deferral.promise;
}
开发者ID:geeklearningio,项目名称:gl-swagger-generator,代码行数:11,代码来源:filesystem.ts

示例10:

 }).catch((err) => {
     if (ErrorHandler.contains(err, "Please tell me who you are")) {
         const defer = Promise.defer();
         EventEmitter.emit(Events.GIT_CHANGE_USERNAME, null, () => {
             EventEmitter.emit(Events.GIT_CHANGE_EMAIL, null, () => {
                 defer.resolve();
             });
         });
         return defer.promise;
     }
     return ErrorHandler.showError(err, "Git Commit failed");
 }).finally(() => {
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:12,代码来源:Panel.ts


注:本文中的bluebird.defer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。