1 | import { noop } from './utils';
|
2 | /**
|
3 | * Provides a set of static methods for creating Disposables.
|
4 | * @param {Function} action Action to run during the first call to dispose.
|
5 | * The action is guaranteed to be run at most once.
|
6 | */
|
7 | export declare class Disposable {
|
8 | /**
|
9 | * Gets the disposable that does nothing when disposed.
|
10 | */
|
11 | static empty: {
|
12 | dispose: typeof noop;
|
13 | };
|
14 | /**
|
15 | * Validates whether the given object is a disposable
|
16 | * @param {Object} Object to test whether it has a dispose method
|
17 | * @returns {Boolean} true if a disposable object, else false.
|
18 | */
|
19 | static isDisposable(d: any): boolean;
|
20 | static _fixup(result: any): any;
|
21 | /**
|
22 | * Creates a disposable object that invokes the specified action when disposed.
|
23 | * @param {Function} dispose Action to run during the first call to dispose.
|
24 | * The action is guaranteed to be run at most once.
|
25 | * @return {Disposable} The disposable object that runs the given action upon disposal.
|
26 | */
|
27 | static create(action: any): Disposable;
|
28 | private isDisposed;
|
29 | private action;
|
30 | constructor(action: any);
|
31 | /** Performs the task of cleaning up resources. */
|
32 | dispose(): void;
|
33 | }
|
34 | /**
|
35 | * Represents a group of disposable resources that are disposed together.
|
36 | * @constructor
|
37 | */
|
38 | export declare class CompositeDisposable {
|
39 | private isDisposed;
|
40 | private disposables;
|
41 | constructor(...disposables: Disposable[]);
|
42 | /**
|
43 | * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
|
44 | * @param {Any} item Disposable to add.
|
45 | */
|
46 | add(item: Disposable): void;
|
47 | /**
|
48 | * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
|
49 | * @param {Any} item Disposable to remove.
|
50 | * Boolean} true if found; false otherwise.
{ |
51 | */
|
52 | remove(item: Disposable): boolean;
|
53 | /**
|
54 | * Disposes all disposables in the group and removes them from the group but
|
55 | * does not dispose the CompositeDisposable.
|
56 | */
|
57 | clear(): void;
|
58 | /**
|
59 | * Disposes all disposables in the group and removes them from the group.
|
60 | */
|
61 | dispose(): void;
|
62 | }
|
63 | /**
|
64 | * Represents a disposable resource whose underlying disposable resource can
|
65 | * be replaced by another disposable resource, causing automatic disposal of
|
66 | * the previous underlying disposable resource.
|
67 | */
|
68 | export declare class SerialDisposable {
|
69 | private isDisposed;
|
70 | private current;
|
71 | /**
|
72 | * Gets the underlying disposable.
|
73 | * @returns {Any} the underlying disposable.
|
74 | */
|
75 | getDisposable(): Disposable | undefined;
|
76 | setDisposable(value: Disposable): void;
|
77 | /** Performs the task of cleaning up resources. */
|
78 | dispose(): void;
|
79 | }
|