mirror of
https://github.com/Microsoft/vscode
synced 2024-10-31 07:52:49 +00:00
debt - a tiny bit of promise removal
This commit is contained in:
parent
9842fb4d61
commit
f8dad22a02
2 changed files with 4 additions and 5 deletions
|
@ -8,7 +8,6 @@ import { onUnexpectedError } from 'vs/base/common/errors';
|
|||
import { once as onceFn } from 'vs/base/common/functional';
|
||||
import { combinedDisposable, Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { LinkedList } from 'vs/base/common/linkedList';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
/**
|
||||
* To an event a function with one or zero parameters
|
||||
|
@ -277,7 +276,7 @@ export function fromCallback<T>(fn: (handler: (e: T) => void) => IDisposable): E
|
|||
return emitter.event;
|
||||
}
|
||||
|
||||
export function fromPromise<T =any>(promise: TPromise<T>): Event<T> {
|
||||
export function fromPromise<T =any>(promise: Thenable<T>): Event<T> {
|
||||
const emitter = new Emitter<T>();
|
||||
let shouldEmit = false;
|
||||
|
||||
|
@ -295,8 +294,8 @@ export function fromPromise<T =any>(promise: TPromise<T>): Event<T> {
|
|||
return emitter.event;
|
||||
}
|
||||
|
||||
export function toPromise<T>(event: Event<T>): TPromise<T> {
|
||||
return new TPromise(complete => {
|
||||
export function toPromise<T>(event: Event<T>): Promise<T> {
|
||||
return new Promise(complete => {
|
||||
const sub = event(e => {
|
||||
sub.dispose();
|
||||
complete(e);
|
||||
|
|
|
@ -375,7 +375,7 @@ export class ChannelClient implements IChannelClient, IDisposable {
|
|||
if (this.state === State.Idle) {
|
||||
return TPromise.as(null);
|
||||
} else {
|
||||
return toPromise(this.onDidInitialize);
|
||||
return TPromise.wrap(toPromise(this.onDidInitialize));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue