forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatchers.ts
More file actions
33 lines (27 loc) · 1.12 KB
/
watchers.ts
File metadata and controls
33 lines (27 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { Event } from 'vscode';
import { IDisposable } from '../../common/types';
import { Disposables } from '../../common/utils/resourceLifecycle';
import { IPythonEnvsWatcher, PythonEnvsChangedEvent, PythonEnvsWatcher } from './watcher';
/**
* A wrapper around a set of watchers, exposing them as a single watcher.
*
* If any of the wrapped watchers emits an event then this wrapper
* emits that event.
*/
export class PythonEnvsWatchers implements IPythonEnvsWatcher, IDisposable {
public readonly onChanged: Event<PythonEnvsChangedEvent>;
private readonly watcher = new PythonEnvsWatcher();
private readonly disposables = new Disposables();
constructor(watchers: ReadonlyArray<IPythonEnvsWatcher>) {
this.onChanged = this.watcher.onChanged;
watchers.forEach((w) => {
const disposable = w.onChanged((e) => this.watcher.fire(e));
this.disposables.push(disposable);
});
}
public async dispose(): Promise<void> {
await this.disposables.dispose();
}
}