本文整理汇总了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;
}
示例2: show
export function show(_pullConfig) {
defer = Promise.defer();
pullConfig = _pullConfig;
pullConfig.pull = true;
RemoteCommon.collectInfo(pullConfig).then(_show);
return defer.promise;
}
示例3: existsAsync
export function existsAsync(path: string): Promise<boolean>{
var deferral = Promise.defer();
fs.exists(path, (res) => {
deferral.resolve(res);
});
return deferral.promise;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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(() => {