Introduce Disposable abstract class

This commit is contained in:
Daniel Imms
2018-06-21 10:24:37 +10:00
parent a44f496ec7
commit dfd17be8bb
4 changed files with 30 additions and 11 deletions
+22
View File
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IDisposable } from 'xterm';
export abstract class Disposable implements IDisposable {
protected _disposables: IDisposable[] = [];
constructor() {
}
public dispose(): void {
this._disposables.forEach(d => d.dispose());
this._disposables.length = 0;
}
public register<T extends IDisposable>(t: T): void {
this._disposables.push(t);
}
}