lifecycle-utils
    Preparing search index...

    Class DisposeAggregator

    DisposeAggregator is a utility class that allows you to add multiple items and then dispose them all at once. You can add a function to call, an object with a dispose method, or an object with a Symbol.dispose method. To dispose all the items, call dispose or use the Symbol.dispose symbol.

    For example,

    const disposeAggregator = new DisposeAggregator();

    const eventRelay = new EventRelay<string>();
    disposeAggregator.add(eventRelay);

    const eventRelay2 = disposeAggregator.add(new EventRelay<string>());

    disposeAggregator.dispose();
    console.log(eventRelay.disposed === true); // true
    console.log(eventRelay2.disposed === true); // true
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Disposes all the targets that have been added and clears the list of targets.

      After all the targets have been disposed, if any throws an error, then the error from the first such target will be thrown.

      Returns void