15 lines
289 B
JavaScript
15 lines
289 B
JavaScript
|
export default class Disposable {
|
||
|
constructor() {
|
||
|
this.disposers = new Set();
|
||
|
}
|
||
|
|
||
|
add(...disposers) {
|
||
|
disposers.forEach(disposer => this.disposers.add(disposer));
|
||
|
}
|
||
|
|
||
|
dispose() {
|
||
|
this.disposers.forEach(disposer => disposer.dispose());
|
||
|
this.disposers.clear();
|
||
|
}
|
||
|
}
|