-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
basemanager.ts
116 lines (100 loc) · 2.55 KB
/
basemanager.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { IObservableDisposable } from '@lumino/disposable';
import { ISignal, Signal } from '@lumino/signaling';
import { ServerConnection } from './serverconnection';
/**
* Object which manages kernel instances for a given base url.
*
* #### Notes
* The manager is responsible for maintaining the state of kernel specs.
*/
export interface IManager extends IObservableDisposable {
/**
* A signal emitted when there is a connection failure.
*/
connectionFailure: ISignal<IManager, ServerConnection.NetworkError>;
/**
* The server settings for the manager.
*/
readonly serverSettings: ServerConnection.ISettings;
/**
* Whether the manager is ready.
*/
readonly isReady: boolean;
/**
* A promise that resolves when the manager is initially ready.
*/
readonly ready: Promise<void>;
/**
* Whether the manager is active.
*/
readonly isActive: boolean;
}
export abstract class BaseManager implements IManager {
constructor(options: BaseManager.IOptions) {
this.serverSettings =
options.serverSettings ?? ServerConnection.makeSettings();
}
/**
* A signal emitted when the delegate is disposed.
*/
get disposed(): ISignal<this, void> {
return this._disposed;
}
/**
* A signal emitted when there is a connection failure.
*/
abstract connectionFailure: ISignal<this, Error>;
/**
* Test whether the delegate has been disposed.
*/
get isDisposed(): boolean {
return this._isDisposed;
}
/**
* Test whether the manager is ready.
*/
abstract isReady: boolean;
/**
* A promise that fulfills when the manager is ready.
*/
abstract ready: Promise<void>;
/**
* Whether the manager is active.
*/
get isActive(): boolean {
return true;
}
/**
* Dispose of the delegate and invoke the callback function.
*/
dispose(): void {
if (this.isDisposed) {
return;
}
this._isDisposed = true;
this._disposed.emit(undefined);
Signal.clearData(this);
}
/**
* The server settings of the manager.
*/
readonly serverSettings: ServerConnection.ISettings;
private _isDisposed = false;
private _disposed = new Signal<this, void>(this);
}
/**
* The namespace for `BaseManager` class statics.
*/
export namespace BaseManager {
/**
* The options used to initialize a SessionManager.
*/
export interface IOptions {
/**
* The server settings for the manager.
*/
serverSettings?: ServerConnection.ISettings;
}
}