提交 650a18e3 编写于 作者: J Johannes Rieken

debt - less TPromise in service interface

上级 340133ac
......@@ -6,18 +6,16 @@
import { URI } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
export const ID = 'urlService';
export const IURLService = createDecorator<IURLService>(ID);
export const IURLService = createDecorator<IURLService>('urlService');
export interface IURLHandler {
handleURL(uri: URI): TPromise<boolean>;
handleURL(uri: URI): Thenable<boolean>;
}
export interface IURLService {
_serviceBrand: any;
open(url: URI): TPromise<boolean>;
open(url: URI): Thenable<boolean>;
registerHandler(handler: IURLHandler): IDisposable;
}
......@@ -6,7 +6,6 @@
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
import { URI } from 'vs/base/common/uri';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import { first } from 'vs/base/common/async';
declare module Array {
......@@ -19,7 +18,7 @@ export class URLService implements IURLService {
private handlers = new Set<IURLHandler>();
open(uri: URI): TPromise<boolean> {
open(uri: URI): Thenable<boolean> {
const handlers = Array.from(this.handlers);
return first(handlers.map(h => () => h.handleURL(uri)), undefined, false);
}
......@@ -36,11 +35,11 @@ export class RelayURLService extends URLService implements IURLHandler {
super();
}
open(uri: URI): TPromise<boolean> {
open(uri: URI): Thenable<boolean> {
return this.urlService.open(uri);
}
handleURL(uri: URI): TPromise<boolean> {
handleURL(uri: URI): Thenable<boolean> {
return super.open(uri);
}
}
\ No newline at end of file
}
......@@ -38,8 +38,8 @@ export class URLServiceChannelClient implements IURLService {
constructor(private channel: IChannel) { }
open(url: URI): TPromise<boolean> {
return TPromise.wrap(this.channel.call('open', url.toJSON()));
open(url: URI): Thenable<boolean> {
return this.channel.call('open', url.toJSON());
}
registerHandler(handler: IURLHandler): IDisposable {
......@@ -76,4 +76,4 @@ export class URLHandlerChannelClient implements IURLHandler {
handleURL(uri: URI): TPromise<boolean> {
return TPromise.wrap(this.channel.call('handleURL', uri.toJSON()));
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册