提交 575cbbde 编写于 作者: J Johannes Rieken

debt - Delete event provider, #1522

上级 53d63951
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import lifecycle = require('vs/base/common/lifecycle');
export interface EventProvider<T extends Function> {
add(callback: T, context?: any, bucket?: lifecycle.IDisposable[]): void;
remove(callback: T, context?: any): void;
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import CallbackList from 'vs/base/common/callbackList';
import { EventProvider } from 'vs/base/common/eventProvider';
export class EventSource<T extends Function> {
private _value: CallbackList;
public fire(...args: any[]): any[] {
if(!this._value) {
return;
}
return this._value.invoke.apply(this._value, args);
}
public get value(): EventProvider<T> {
if(!this._value) {
this._value = new CallbackList();
}
return {
add: (callback, context?, bucket?) => {
this._value.add(callback, context, bucket);
},
remove: this._value.remove.bind(this._value)
};
}
}
......@@ -8,7 +8,6 @@ import * as assert from 'assert';
import Event, {Emitter, fromEventEmitter} from 'vs/base/common/event';
import {IDisposable} from 'vs/base/common/lifecycle';
import {EventEmitter} from 'vs/base/common/eventEmitter';
import {EventSource} from 'vs/base/common/eventSource';
import Errors = require('vs/base/common/errors');
namespace Samples {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册