Skip to content

Commit

Permalink
Adjust DisposableCollection description
Browse files Browse the repository at this point in the history
Improved description based on Martin's feedback.
  • Loading branch information
jcortell68 committed Feb 2, 2024
1 parent d74cef1 commit a40064a
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions packages/core/src/common/disposable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,20 @@ Object.defineProperty(Disposable, 'NULL', {
});

/**
* Utility for tracking a collection of Disposable objects, specifically for
* the sake of finding out when all items in the collection have been disposed.
* Utility for tracking a collection of Disposable objects.
*
* This utility provides a number of benefits over just using an array of
* Disposables:
*
* - the collection is auto-pruned when an element it contains is disposed by
* any code that has a reference to it
* - you can register to be notified when all elements in the collection have
* been disposed
* - you can conveniently dispose all elements by calling dipose()
* on the collection
*
* Unlike an array, however, this utility does not give you direct access to
* its elements.
*
* ```
* const dc = new DisposableCollection(myDisposables);
Expand All @@ -58,18 +70,10 @@ Object.defineProperty(Disposable, 'NULL', {
* });
* ```
*
* You can add any number of Disposables to the collection at any time. You
* cannot query the contents of the collection. An element is automatically
* pruned from the collection when it is disposed.
*
* The collection will notify only once. It will continue to function
* in so far as accepting new Disposables and pruning them when they
* are disposed, but such activity will never result in another
* notification.
*
* Calling dispose() on the collection disposes all its elements. A notification
* is sent (if no notification was previously sent).
*/
* [*] The collection will notify only once. It will continue to function in so
* far as accepting new Disposables and pruning them when they are disposed, but
* such activity will never result in another notification.
*/
export class DisposableCollection implements Disposable {

protected readonly disposables: Disposable[] = [];
Expand Down

0 comments on commit a40064a

Please sign in to comment.