• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript bluebird.finally函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: if

        .then((pushConfig) => {
            let q: Promise<any> = Promise.resolve();
            const additionalArgs = [];

            if (pushConfig.tags) {
                additionalArgs.push("--tags");
            }

            // set a new tracking branch if desired
            if (pushConfig.branch && pushConfig.setBranchAsTracking) {
                q = q.then(() => Git.setUpstreamBranch(pushConfig.remote, pushConfig.branch));
            }
            // put username and password into remote url
            if (pushConfig.remoteUrlNew) {
                q = q.then(() => Git2.setRemoteUrl(pushConfig.remote, pushConfig.remoteUrlNew));
            }
            // do the pull itself (we are not using pull command)
            q = q.then(() => {
                let op;

                if (pushConfig.pushToNew) {
                    op = Git2.pushToNewUpstream(pushConfig.remote, pushConfig.branch);
                } else if (pushConfig.strategy === "DEFAULT") {
                    op = Git.push(pushConfig.remote, pushConfig.branch, additionalArgs);
                } else if (pushConfig.strategy === "FORCED") {
                    op = Git2.pushForced(pushConfig.remote, pushConfig.branch);
                } else if (pushConfig.strategy === "DELETE_BRANCH") {
                    op = Git2.deleteRemoteBranch(pushConfig.remote, pushConfig.branch);
                }
                return ProgressDialog.show(op)
                    .then((result) => {
                        return ProgressDialog.waitForClose().then(() => {
                            showPushResult(result);
                        });
                    })
                    .catch((err) => ErrorHandler.showError(err, "Pushing to remote failed"));
            });
            // restore original url if desired
            if (pushConfig.remoteUrlRestore) {
                q = q.finally(() => Git2.setRemoteUrl(pushConfig.remote, pushConfig.remoteUrlRestore));
            }

            return q.finally(() => EventEmitter.emit(Events.REFRESH_ALL));
        })
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:44,代码来源:Remotes.ts


示例2:

            CloneDialog.show().then((cloneConfig) => {
                let q: Promise<any> = Promise.resolve();
                // put username and password into remote url
                let remoteUrl = cloneConfig.remoteUrl;
                if (cloneConfig.remoteUrlNew) {
                    remoteUrl = cloneConfig.remoteUrlNew;
                }

                // do the clone
                q = q.then(() => ProgressDialog.show(Git.clone(remoteUrl, ".")))
                    .catch((err) => ErrorHandler.showError(err, "Cloning remote repository failed!"));

                // restore original url if desired
                if (cloneConfig.remoteUrlRestore) {
                    q = q.then(() => Git2.setRemoteUrl(cloneConfig.remote, cloneConfig.remoteUrlRestore));
                }

                return q.finally(() => EventEmitter.emit(Events.REFRESH_ALL));
            }).catch((err) => {
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:19,代码来源:NoRepo.ts


示例3: connectToNode

// return true/false to state if wasConnected before
function connectToNode() {
    if (connectPromise) {
        return connectPromise;
    }

    const moduleDirectory = Utils.getExtensionDirectory();
    const domainModulePath = moduleDirectory + "dist/node/cli";

    connectPromise = new Promise((resolve, reject) => {
        if (nodeConnection.connected()) {
            return resolve(true);
        }
        // we don't want automatic reconnections as we handle the reconnect manually
        nodeConnection.connect(false).then(() => {
            nodeConnection.loadDomains([domainModulePath], false).then(() => {
                attachEventHandlers();
                resolve(false);
            }).fail((err) => { // jQuery promise - .fail is fine
                reject(ErrorHandler.toError(err));
            });
        }).fail((err) => { // jQuery promise - .fail is fine
            if (ErrorHandler.contains(err, "Max connection attempts reached")) {
                Utils.consoleLog("Max connection attempts reached, trying again.", "warn");
                // try again
                connectPromise = null;
                connectToNode()
                    .then((result) => { resolve(result); })
                    .catch((err2) => { reject(err2); });
                return;
            }
            reject(ErrorHandler.toError(err));
        });
    });

    connectPromise.finally(() => connectPromise = null);

    return connectPromise;
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:39,代码来源:Cli.ts


示例4:

fooProm.catch(booObject1, booObject2, booObject3, error => {});
// $ExpectType Bluebird<void | Foo>
fooProm.catch(booObject1, booObject2, booObject3, booObject4, error => {});
// $ExpectType Bluebird<void | Foo>
fooProm.catch(booObject1, booObject2, booObject3, booObject4, booObject5, error => {});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

barProm = fooProm.error((reason: any) => {
	return bar;
});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fooProm = fooProm.finally(() => {
	// non-Thenable return is ignored
	return "foo";
});
fooProm = fooProm.finally(() => {
	return fooThen;
});
fooProm = fooProm.finally(() => {
	// non-Thenable return is ignored
});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fooProm = fooProm.lastly(() => {
	// non-Thenable return is ignored
	return "foo";
});
fooProm = fooProm.lastly(() => {
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:32,代码来源:bluebird-tests.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript bluebird.fromCallback函数代码示例发布时间:2022-05-25
下一篇:
TypeScript bluebird.each函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap