@bodil/core - v0.4.5
    Preparing search index...

    Class DisposableContext

    A reentrant version of DisposableStack.

    This maintains a list of Disposables, added with the DisposableContext.use method, which will all be disposed when you dispose of the DisposableContext itself.

    Where this differs from DisposableStack is that disposing it only resets it after disposing of its dependents, and you can reuse it as many times as you like. This is very handy for managing lifecycle resources, eg. a web component can allocate resources in its connectedCallback method and during its connected lifecycle phase which can all be disposed in disconnectedCallback with a single call to DisposableContext.dispose, and it's instantly ready to go again on reconnect.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    dispose: (() => void) | (() => void) = ...

    Disposes the resources currently held by this context.

    Methods

    • Type Parameters

      • A

      Parameters

      • value: A
      • onDispose: (value: A) => void

      Returns A