platform-bible-utils
    Preparing search index...

    Class UnsubscriberAsyncList

    Simple collection for UnsubscriberAsync objects that also provides an easy way to run them.

    A list is single-use: it collects unsubscribers until runAllUnsubscribers runs them, and that run seals it for good. Anything added to a sealed list is unsubscribed immediately instead of being stored, because whatever these clean up after is already gone. Registration is usually asynchronous, so an unsubscriber routinely arrives after the teardown that should have run it — without sealing it would be stored in a list nobody drains again and its subscription would leak for the rest of the session.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    unsubscribers: Set<Unsubscriber | UnsubscriberAsync> = ...

    Methods

    • Add unsubscribers to the list. Note that duplicates are not added twice.

      Once runAllUnsubscribers has started, unsubscribers are run immediately rather than stored. Nothing can await that run, so its outcome — success included — is only reported.

      Those reports are rate-limited: within a LATE_ARRIVAL_REPORT_WINDOW_MS window, lists sharing this list's name report the first occurrence of each outcome verbatim and then collapse the rest into one count. So the reports are a faithful signal that late arrivals are happening, but not a per-occurrence record — do not count log lines to count undone subscriptions.

      Parameters

      Returns void

    • Run all unsubscribers added to this list, clear the list, and seal it so anything added later is unsubscribed on arrival.

      An unsubscriber that throws (synchronously or asynchronously) does not make this method reject: the error is caught and logged via console.error, the remaining unsubscribers still run, and the thrower counts as a failure in the return value. An unsubscriber that arrives during the run is not part of the returned result — nothing is waiting on it by then.

      Returns Promise<boolean>

      true if all unsubscribers succeeded, false if any returned false or threw.