debian-mirror-gitlab/app/assets/javascripts/ide/lib/common/disposable.js

15 lines
293 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
export default class Disposable {
constructor() {
this.disposers = new Set();
}
add(...disposers) {
2021-03-08 18:12:59 +05:30
disposers.forEach((disposer) => this.disposers.add(disposer));
2018-05-09 12:01:36 +05:30
}
dispose() {
2021-03-08 18:12:59 +05:30
this.disposers.forEach((disposer) => disposer.dispose());
2018-05-09 12:01:36 +05:30
this.disposers.clear();
}
}