abstractContext
Hierarchy
- Context
Index
Constructors
Methods
Constructors
constructor
Returns Context
Methods
clear
Clear the current context: detach and destroys all children context. The context can be reused.
Returns void
destroy
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
Whether the context is destroyed.
Returns boolean
offClear
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
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
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
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
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