本文整理匯總了TypeScript中vs/base/common/winjs.base.TPromise.then方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript base.TPromise.then方法的具體用法?TypeScript base.TPromise.then怎麽用?TypeScript base.TPromise.then使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/common/winjs.base.TPromise
的用法示例。
在下文中一共展示了base.TPromise.then方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: activateById
public activateById(extensionId: string): TPromise<void> {
return this._onReady.then(() => {
let desc = ExtensionsRegistry.getExtensionDescription(extensionId);
if (!desc) {
throw new Error('Extension `' + extensionId + '` is not known');
}
return this._activateExtensions([desc], 0);
});
}
示例2: triggerAutoSuggest
private triggerAutoSuggest(marker: IMarker): void {
if (this.enableAutoQuckFix && this.state === QuickFixSuggestState.NOT_ACTIVE) {
this.triggerAutoSuggestPromise = TPromise.timeout(this.autoSuggestDelay);
this.triggerAutoSuggestPromise.then(() => {
this.triggerAutoSuggestPromise = null;
if (marker === this.lastMarker) {
this.triggerDialog(true, this.editor.getPosition());
}
});
}
}
示例3: main
export function main(argv: string[]): TPromise<void> {
let args: ParsedArgs;
try {
args = parseCLIProcessArgv(argv);
} catch (err) {
console.error(err.message);
return TPromise.as(null);
}
if (args.help) {
console.log(buildHelpMessage(product.nameLong, product.applicationName, pkg.version));
} else if (args.version) {
console.log(`${pkg.version}\n${product.commit}`);
} else if (shouldSpawnCliProcess(args)) {
const mainCli = new TPromise<IMainCli>(c => require(['vs/code/node/cliProcessMain'], c));
return mainCli.then(cli => cli.main(args));
} else {
const env = assign({}, process.env, {
// this will signal Code that it was spawned from this module
'VSCODE_CLI': '1',
'ELECTRON_NO_ATTACH_CONSOLE': '1'
});
delete env['ELECTRON_RUN_AS_NODE'];
if (args.verbose) {
env['ELECTRON_ENABLE_LOGGING'] = '1';
}
const options = {
detached: true,
env,
};
if (!args.verbose) {
options['stdio'] = 'ignore';
}
const child = spawn(process.execPath, argv.slice(2), options);
if (args.verbose) {
child.stdout.on('data', (data) => console.log(data.toString('utf8').trim()));
child.stderr.on('data', (data) => console.log(data.toString('utf8').trim()));
}
if (args.wait || args.verbose) {
return new TPromise<void>(c => child.once('exit', () => c(null)));
}
}
return TPromise.as(null);
}
示例4:
const result = new TPromise<void>((c, e, p) => {
request.then(c, e, p).done(() => {
if (!this.activeRequests) {
return;
}
this.activeRequests.splice(this.activeRequests.indexOf(result), 1);
if (this.activeRequests.length === 0) {
this.disposeDelayer.trigger(() => this.disposeClient());
}
});
}, () => request.cancel());
示例5: constructor
constructor(outer: TPromise<T>) {
var completeCallback: ValueCallback,
errorCallback: ErrorCallback,
progressCallback: ProgressCallback;
super((c, e, p) => {
completeCallback = c,
errorCallback = e;
progressCallback = p;
}, () => {
// cancel this promise but not the
// outer promise
errorCallback(errors.canceled());
});
outer.then(completeCallback, errorCallback, progressCallback);
}
示例6: getResults
public getResults(input: string): TPromise<Model.QuickOpenModel> {
return this.tasks.then((tasks) => {
let entries: Model.QuickOpenEntry[] = [];
if (tasks.length === 0) {
return new Model.QuickOpenModel(entries);
}
tasks = tasks.sort((a, b) => {
let aKind = a._source.kind;
let bKind = b._source.kind;
if (aKind === bKind) {
return a.name.localeCompare(b.name);
}
if (aKind === TaskSourceKind.Workspace) {
return -1;
} else {
return +1;
}
});
let hasWorkspace: boolean = tasks[0]._source.kind === TaskSourceKind.Workspace;
let hasExtension: boolean = tasks[tasks.length - 1]._source.kind === TaskSourceKind.Extension;
let groupWorkspace = hasWorkspace && hasExtension;
let groupExtension = groupWorkspace;
let hadWorkspace = false;
for (let task of tasks) {
let highlights = Filters.matchesContiguousSubString(input, task.name);
if (!highlights) {
continue;
}
if (task._source.kind === TaskSourceKind.Workspace && groupWorkspace) {
groupWorkspace = false;
hadWorkspace = true;
entries.push(new TaskGroupEntry(this.createEntry(this.taskService, task, highlights), nls.localize('workspace', 'From Workspace'), false));
} else if (task._source.kind === TaskSourceKind.Extension && groupExtension) {
groupExtension = false;
entries.push(new TaskGroupEntry(this.createEntry(this.taskService, task, highlights), nls.localize('extension', 'From Extensions'), hadWorkspace));
} else {
entries.push(this.createEntry(this.taskService, task, highlights));
}
}
return new Model.QuickOpenModel(entries);
});
}
示例7: show
show(fixes: TPromise<CodeAction[]>, at: { x: number; y: number } | IPosition) {
const actions = fixes.then(value => {
return value.map(({command}) => {
return new Action(command.id, command.title, undefined, true, () => {
return this._commandService.executeCommand(command.id, ...command.arguments);
});
});
});
this._contextMenuService.showContextMenu({
getAnchor: () => {
if (Position.isIPosition(at)) {
at = this._toCoords(at);
}
return at;
},
getActions: () => actions,
onHide: () => { this._visible = false; }
});
}
示例8: main
export function main(args: string[]): TPromise<void> {
const argv = parseArgs(args);
if (argv.help) {
console.log(helpMessage);
} else if (argv.version) {
console.log(pkg.version);
} else if (shouldSpawnCliProcess(argv)) {
const mainCli = new TPromise<IMainCli>(c => require(['vs/code/node/cliProcessMain'], c));
return mainCli.then(cli => cli.main(argv));
} else {
const env = assign({}, process.env, {
// this will signal Code that it was spawned from this module
'VSCODE_CLI': '1',
'ELECTRON_NO_ATTACH_CONSOLE': '1'
});
delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
let options = {
detacted: true,
env,
};
if (!argv.verbose) {
options['stdio'] = 'ignore';
}
const child = spawn(process.execPath, args, options);
if (argv.verbose) {
child.stdout.on('data', (data) => console.log(data.toString('utf8').trim()));
child.stderr.on('data', (data) => console.log(data.toString('utf8').trim()));
}
if (argv.wait || argv.verbose) {
return new TPromise<void>(c => child.once('exit', () => c(null)));
}
}
return TPromise.as(null);
}
示例9: detectMimetypes
public detectMimetypes(path: string, treeish?: string): TPromise<string[]> {
return this.raw.then(raw => raw.detectMimetypes(path, treeish));
}
示例10: sync
public sync(): TPromise<IRawStatus> {
return this.raw.then(raw => raw.sync());
}