1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | exports.ActivityMonitor = void 0;
|
6 | const signaling_1 = require("@lumino/signaling");
|
7 |
|
8 |
|
9 |
|
10 | class ActivityMonitor {
|
11 | |
12 |
|
13 |
|
14 | constructor(options) {
|
15 | this._timer = -1;
|
16 | this._timeout = -1;
|
17 | this._isDisposed = false;
|
18 | this._activityStopped = new signaling_1.Signal(this);
|
19 | options.signal.connect(this._onSignalFired, this);
|
20 | this._timeout = options.timeout || 1000;
|
21 | }
|
22 | |
23 |
|
24 |
|
25 | get activityStopped() {
|
26 | return this._activityStopped;
|
27 | }
|
28 | |
29 |
|
30 |
|
31 | get timeout() {
|
32 | return this._timeout;
|
33 | }
|
34 | set timeout(value) {
|
35 | this._timeout = value;
|
36 | }
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | get isDisposed() {
|
44 | return this._isDisposed;
|
45 | }
|
46 | |
47 |
|
48 |
|
49 | dispose() {
|
50 | if (this._isDisposed) {
|
51 | return;
|
52 | }
|
53 | this._isDisposed = true;
|
54 | signaling_1.Signal.clearData(this);
|
55 | }
|
56 | |
57 |
|
58 |
|
59 | _onSignalFired(sender, args) {
|
60 | clearTimeout(this._timer);
|
61 | this._sender = sender;
|
62 | this._args = args;
|
63 | this._timer = setTimeout(() => {
|
64 | this._activityStopped.emit({
|
65 | sender: this._sender,
|
66 | args: this._args
|
67 | });
|
68 | }, this._timeout);
|
69 | }
|
70 | }
|
71 | exports.ActivityMonitor = ActivityMonitor;
|
72 |
|
\ | No newline at end of file |