forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignal.ts
More file actions
26 lines (22 loc) · 830 Bytes
/
Copy pathsignal.ts
File metadata and controls
26 lines (22 loc) · 830 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { ISignal, Slot } from '@phosphor/signaling';
export class Signal<T, S> implements ISignal<T, S> {
private slots: Set<Slot<T, S>> = new Set<Slot<T, S>>();
// tslint:disable-next-line: no-any
public connect(slot: Slot<T, S>, thisArg?: any): boolean {
const bound = thisArg ? slot.bind(thisArg) : slot;
this.slots.add(bound);
return true;
}
// tslint:disable-next-line: no-any
public disconnect(slot: Slot<T, S>, thisArg?: any): boolean {
const bound = thisArg ? slot.bind(thisArg) : slot;
this.slots.delete(bound);
return true;
}
public fire(sender: T, args: S): void {
this.slots.forEach((s) => s(sender, args));
}
}