Class: DisposalScope

DisposalScope(nameopt)

Collects teardown callbacks and releases them together.

Constructor

new DisposalScope(nameopt)

Parameters:
Name Type Attributes Default Description
name string <optional>
scope

Debug label used in diagnostics.

Source:

Classes

DisposalScope

Members

disposed :boolean

Type:
  • boolean
Source:

disposers :Set:.<function()>

Type:
  • Set:.<function()>
Source:

name :string

Type:
  • string
Source:

Methods

add(disposer) → {function}

Registers a teardown callback with this scope. Disposing the scope runs it; running it earlier removes it from the scope.

Parameters:
Name Type Description
disposer function

The teardown callback.

Source:
Returns:

A wrapper that runs the teardown at most once.

Type
function

dispose()

Runs every registered teardown callback and empties the scope. Safe to call more than once.

Source: