本文整理匯總了TypeScript中vs/base/common/winjs.base.Promise.as方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript base.Promise.as方法的具體用法?TypeScript base.Promise.as怎麽用?TypeScript base.Promise.as使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/common/winjs.base.Promise
的用法示例。
在下文中一共展示了base.Promise.as方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: next
export function sequence<T>(promiseFactory: ITask<TPromise<T>>[]): TPromise<T[]> {
var results: T[] = [];
// Reverse since we start with last element using pop()
promiseFactory = promiseFactory.reverse();
function next(): Promise {
if (promiseFactory.length) {
return promiseFactory.pop()();
}
return null;
}
function thenHandler(result: any): Promise {
if (result) {
results.push(result);
}
var n = next();
if (n) {
return n.then(thenHandler);
}
return TPromise.as(results);
}
return Promise.as(null).then(thenHandler);
}
示例2:
return this.repo.fetch().then(null, (err) => {
if (err.gitErrorCode === GitErrorCodes.NoRemoteRepositorySpecified) {
return Promise.as(null);
}
return Promise.wrapError(err);
}).then(() => this.status());
示例3: commit
public commit(message:string, amend?: boolean, stage?: boolean): TPromise<IRawStatus> {
var promise: Promise = Promise.as(null);
if (stage) {
promise = this.repo.add(null);
}
return promise
.then(() => this.repo.commit(message, stage, amend))
.then(() => this.status());
}
示例4: start
public start(args: env.ICommandLineArguments): Promise {
env.log('Received data from other instance', args);
// Otherwise handle in windows manager
if (!!args.pluginDevelopmentPath) {
windows.manager.openPluginDevelopmentHostWindow({ cli: args });
} else if (args.pathArguments.length === 0 && args.openNewWindow) {
windows.manager.open({ cli: args, forceNewWindow: true, forceEmpty: true });
} else if (args.pathArguments.length === 0) {
windows.manager.focusLastActive(args);
} else {
windows.manager.open({ cli: args, forceNewWindow: !args.openInSameWindow });
}
return Promise.as(null);
}
示例5: timebomb
function timebomb(): Promise {
if (!env.product.expiryDate || Date.now() <= env.product.expiryDate) {
return Promise.as(null);
}
return new Promise((c, e) => {
dialog.showMessageBox({
type: 'warning',
title: env.product.nameLong,
message: nls.localize('expired', "Expired"),
detail: nls.localize('expiredDetail', "This pre-release version of {0} has expired.\n\nPlease visit {1} to download the current release.", env.product.nameLong, env.product.expiryUrl),
buttons: [nls.localize('quit', "Quit"), nls.localize('openWebSite', "Open Web Site")],
noLink: true,
}, (i) => {
if (i === 1) {
shell.openExternal(env.product.expiryUrl);
}
e('Product expired');
});
});
}
示例7: getParent
getParent(tree: ITree, element: any): Promise {
return Promise.as(null);
}
示例8: getChildren
getChildren(tree: ITree, element: any): Promise {
const model = this.modelProvider.getModel();
return Promise.as(model === element ? model.entries : []);
}
示例9:
var factoryFactory = (n: number) => () => {
return Promise.as(n);
};