1 | import { IterableOrArrayLike } from '@lumino/algorithm';
|
2 | import { ISignal } from '@lumino/signaling';
|
3 | /**
|
4 | * An object which implements the disposable pattern.
|
5 | */
|
6 | export interface IDisposable {
|
7 | /**
|
8 | * Test whether the object has been disposed.
|
9 | *
|
10 | * #### Notes
|
11 | * This property is always safe to access.
|
12 | */
|
13 | readonly isDisposed: boolean;
|
14 | /**
|
15 | * Dispose of the resources held by the object.
|
16 | *
|
17 | * #### Notes
|
18 | * If the object's `dispose` method is called more than once, all
|
19 | * calls made after the first will be a no-op.
|
20 | *
|
21 | * #### Undefined Behavior
|
22 | * It is undefined behavior to use any functionality of the object
|
23 | * after it has been disposed unless otherwise explicitly noted.
|
24 | */
|
25 | dispose(): void;
|
26 | }
|
27 | /**
|
28 | * A disposable object with an observable `disposed` signal.
|
29 | */
|
30 | export interface IObservableDisposable extends IDisposable {
|
31 | /**
|
32 | * A signal emitted when the object is disposed.
|
33 | */
|
34 | readonly disposed: ISignal<this, void>;
|
35 | }
|
36 | /**
|
37 | * A disposable object which delegates to a callback function.
|
38 | */
|
39 | export declare class DisposableDelegate implements IDisposable {
|
40 | /**
|
41 | * Construct a new disposable delegate.
|
42 | *
|
43 | * @param fn - The callback function to invoke on dispose.
|
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 | * A signal emitted when the delegate is disposed.
|
62 | */
|
63 | readonly disposed: ISignal<this, void>;
|
64 | /**
|
65 | * Dispose of the delegate and invoke the callback function.
|
66 | */
|
67 | dispose(): void;
|
68 | private _disposed;
|
69 | }
|
70 | /**
|
71 | * An object which manages a collection of disposable items.
|
72 | */
|
73 | export declare class DisposableSet implements IDisposable {
|
74 | /**
|
75 | * Test whether the set has been disposed.
|
76 | */
|
77 | readonly isDisposed: boolean;
|
78 | /**
|
79 | * Dispose of the set and the items it contains.
|
80 | *
|
81 | * #### Notes
|
82 | * Items are disposed in the order they are added to the set.
|
83 | */
|
84 | dispose(): void;
|
85 | /**
|
86 | * Test whether the set contains a specific item.
|
87 | *
|
88 | * @param item - The item of interest.
|
89 | *
|
90 | * @returns `true` if the set contains the item, `false` otherwise.
|
91 | */
|
92 | contains(item: IDisposable): boolean;
|
93 | /**
|
94 | * Add a disposable item to the set.
|
95 | *
|
96 | * @param item - The item to add to the set.
|
97 | *
|
98 | * #### Notes
|
99 | * If the item is already contained in the set, this is a no-op.
|
100 | */
|
101 | add(item: IDisposable): void;
|
102 | /**
|
103 | * Remove a disposable item from the set.
|
104 | *
|
105 | * @param item - The item to remove from the set.
|
106 | *
|
107 | * #### Notes
|
108 | * If the item is not contained in the set, this is a no-op.
|
109 | */
|
110 | remove(item: IDisposable): void;
|
111 | /**
|
112 | * Remove all items from the set.
|
113 | */
|
114 | clear(): void;
|
115 | private _isDisposed;
|
116 | private _items;
|
117 | }
|
118 | /**
|
119 | * The namespace for the `DisposableSet` class statics.
|
120 | */
|
121 | export declare namespace DisposableSet {
|
122 | /**
|
123 | * Create a disposable set from an iterable of items.
|
124 | *
|
125 | * @param items - The iterable or array-like object of interest.
|
126 | *
|
127 | * @returns A new disposable initialized with the given items.
|
128 | */
|
129 | function from(items: IterableOrArrayLike<IDisposable>): DisposableSet;
|
130 | }
|
131 | /**
|
132 | * An observable object which manages a collection of disposable items.
|
133 | */
|
134 | export declare class ObservableDisposableSet extends DisposableSet implements IObservableDisposable {
|
135 | /**
|
136 | * A signal emitted when the set is disposed.
|
137 | */
|
138 | readonly disposed: ISignal<this, void>;
|
139 | /**
|
140 | * Dispose of the set and the items it contains.
|
141 | *
|
142 | * #### Notes
|
143 | * Items are disposed in the order they are added to the set.
|
144 | */
|
145 | dispose(): void;
|
146 | private _disposed;
|
147 | }
|
148 | /**
|
149 | * The namespace for the `ObservableDisposableSet` class statics.
|
150 | */
|
151 | export declare namespace ObservableDisposableSet {
|
152 | /**
|
153 | * Create an observable disposable set from an iterable of items.
|
154 | *
|
155 | * @param items - The iterable or array-like object of interest.
|
156 | *
|
157 | * @returns A new disposable initialized with the given items.
|
158 | */
|
159 | function from(items: IterableOrArrayLike<IDisposable>): ObservableDisposableSet;
|
160 | }
|
161 | //# sourceMappingURL=index.d.ts.map |
\ | No newline at end of file |