1 | import { IterableOrArrayLike } from '@phosphor/algorithm';
|
2 | import { ISignal } from '@phosphor/signaling';
|
3 |
|
4 |
|
5 |
|
6 | export interface IDisposable {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | readonly isDisposed: boolean;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | dispose(): void;
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 | export interface IObservableDisposable extends IDisposable {
|
31 | |
32 |
|
33 |
|
34 | readonly disposed: ISignal<this, void>;
|
35 | }
|
36 |
|
37 |
|
38 |
|
39 | export declare class DisposableDelegate implements IDisposable {
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | constructor(fn: () => void);
|
46 | /**
|
47 | * Test whether the delegate has been disposed.
|
48 | */
|
49 | readonly isDisposed: boolean;
|
50 | /**
|
51 | * Dispose of the delegate and invoke the callback function.
|
52 | */
|
53 | dispose(): void;
|
54 | private _fn;
|
55 | }
|
56 | /**
|
57 | * An observable disposable object which delegates to a callback function.
|
58 | */
|
59 | export declare class ObservableDisposableDelegate extends DisposableDelegate implements IObservableDisposable {
|
60 | |
61 |
|
62 |
|
63 | readonly disposed: ISignal<this, void>;
|
64 | |
65 |
|
66 |
|
67 | dispose(): void;
|
68 | private _disposed;
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 | export declare class DisposableSet implements IDisposable {
|
74 | |
75 |
|
76 |
|
77 | constructor();
|
78 | /**
|
79 | * Test whether the set has been disposed.
|
80 | */
|
81 | readonly isDisposed: boolean;
|
82 | /**
|
83 | * Dispose of the set and the items it contains.
|
84 | *
|
85 | * #### Notes
|
86 | * Items are disposed in the order they are added to the set.
|
87 | */
|
88 | dispose(): void;
|
89 | /**
|
90 | * Test whether the set contains a specific item.
|
91 | *
|
92 | * @param item - The item of interest.
|
93 | *
|
94 | * @returns `true` if the set contains the item, `false` otherwise.
|
95 | */
|
96 | contains(item: IDisposable): boolean;
|
97 | /**
|
98 | * Add a disposable item to the set.
|
99 | *
|
100 | * @param item - The item to add to the set.
|
101 | *
|
102 | * #### Notes
|
103 | * If the item is already contained in the set, this is a no-op.
|
104 | */
|
105 | add(item: IDisposable): void;
|
106 | /**
|
107 | * Remove a disposable item from the set.
|
108 | *
|
109 | * @param item - The item to remove from the set.
|
110 | *
|
111 | * #### Notes
|
112 | * If the item is not contained in the set, this is a no-op.
|
113 | */
|
114 | remove(item: IDisposable): void;
|
115 | /**
|
116 | * Remove all items from the set.
|
117 | */
|
118 | clear(): void;
|
119 | private _isDisposed;
|
120 | private _items;
|
121 | }
|
122 | /**
|
123 | * The namespace for the `DisposableSet` class statics.
|
124 | */
|
125 | export declare namespace DisposableSet {
|
126 | |
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | function from(items: IterableOrArrayLike<IDisposable>): DisposableSet;
|
134 | }
|
135 |
|
136 |
|
137 |
|
138 | export declare class ObservableDisposableSet extends DisposableSet implements IObservableDisposable {
|
139 | |
140 |
|
141 |
|
142 | readonly disposed: ISignal<this, void>;
|
143 | |
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 | dispose(): void;
|
150 | private _disposed;
|
151 | }
|
152 |
|
153 |
|
154 |
|
155 | export declare namespace ObservableDisposableSet {
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | function from(items: IterableOrArrayLike<IDisposable>): ObservableDisposableSet;
|
164 | }
|