Skip to main content
Version: 2.8

abstractContext

Softcoded application context

Contexts have parents and children, they represent the lifecycle of bricks. They contain callbacks executed at specific time of the brick lifespan.

Each time a brick is updated with new inputs, Context.clear is called, executing all callbacks registered with Context.onClear.

When a brick is destroyed, Context.destroy is called, executing all callbacks registered with Context.onClear and Context.onDestroy

Hierarchy

Index

Constructors

constructor

Methods

clear

  • clear(): void
  • Clear the current context: detach and destroys all children context. The context can be reused.


    Returns void

destroy

  • destroy(): void
  • Destroy the current context. It destroys all children context attached to this one and clear their values. The context cannot be reused after calling this function.


    Returns void

isDestroyed

  • isDestroyed(): boolean
  • Whether the context is destroyed.


    Returns boolean

offClear

  • offClear(id: string): void
  • Remove a previously registered callback with Context.onClear method using its id.


    Parameters

    • id: string

      the id of the callback to unregister

    Returns void

offDestroy

  • offDestroy(callbackId: string): boolean
  • Remove a previously registered callback with Context.onDestroy method using its id.


    Parameters

    • callbackId: string

      the id of the callback to unregister

    Returns boolean

onClear

  • onClear(callback: () => void): string
  • Register a callback to execute every time the context is cleared. This happens every time the brick is refreshed with new inputs and during the brick destruction. Return the callback id.


    Parameters

    • callback: () => void

      the callback function

    Returns string

    the callback id

onDestroy

  • onDestroy(callback: () => void): string
  • Register a callback to execute when the context is destroyed. Return the callback id.


    Parameters

    • callback: () => void

      the callback function

    Returns string

    the callback id