Class SignalScope

A signal scope which can be used by frameworks to automatically destroy registered destroyable signals when the scope is destroyed. A UI framework for example can create a signal scope for a UI component, set it as active scope and then initialize the component calling the component constructor which might create signals which must be destroyed when component is destroyed. When the framework wants to destroy the component it can destroy the signal scope to automatically destroy any signals created while this scope was active.

Implements

Constructors

  • Creates a new signal scope. When there is already an active signal scope then this already active scope is considered to be a parent scope and the new scope is registered in it as child scope so it is destroyed when the parent scope is destroyed.

    Note that creating a signal scope does not activate it. You have to do this yourself, it can be done it one line: scope = new SignalScope().activate().

    Returns SignalScope

Methods

  • Deactivates this scope if it is currently active.

    Returns this

  • Destroys this scope by destroying all registered destroyable objects and deactivating the scope if it is currently active.

    Returns void

  • Registers the given destroyable object in the current signal scope if present.

    Parameters

    • destroyable: Destroyable

      The destroyable object to register.

    Returns void