Interface: ExecutionContext

olympe.df. ExecutionContext

An Execution Context is an object that keeps track of created nodes to make it easier to destroy them when no longer needed or valid. This is usually a tree as contexts can be attached to a context. Destroying a context will also destroy all its descendents.

Methods


attach(nodeOrProxy)

Attaches a node, or context, to this context.

Parameters:
Name Type Description
nodeOrProxy olympe.df.ExecutionContext | olympe.df.Proxy

The node to attach to this context.


boundTo(func)

Creates a function that is the result of binding the specified function to this context. This means that all nodes created during any execution of the created function will be attached to this context or one of its descendents.

Parameters:
Name Type Description
func T

The function to bind to this context.

Returns:

The created function.

Type
T

contextIsDetaching(context)

Notify this context that it is being detached from its parent.

Parameters:
Name Type Description
context olympe.df.ExecutionContext

<abstract> destroy()

Destroy this context and all its dependents.


detach(nodeOrProxy [, autoDestroy])

Detaches a node from this context. If autoDestroy is true (the default), then the detached node might be garbage collected if there aren't any nodes left depending on its value.

Parameters:
Name Type Argument Default Description
nodeOrProxy olympe.df.ExecutionContext | olympe.df.Proxy

The node to detach.

autoDestroy boolean <optional>
true

true to destroy if garbage collection conditions are met, false to keep no matter what.


detachAll()

Detaches all nodes in this context, and checks whether the nodes should be garbage collected.


<abstract> getChildren()

Returns the children attached to this context.

Returns:

The map of the children.

Type
Map.<string, !olympe.df.ExecutionContext>

getDebugName()

Gets the debug name for this ExecutionContext.

Returns:

The debug name.

Type
string

getId()

Returns the ID for this context.

Returns:

The ID.

Type
string

<abstract> getParent()

Returns the parent context for this context, or null if doesn't have one.

Returns:

The parent context.

Type
olympe.df.ExecutionContext

isDestroyed()

Checks whether this context has been already destroyed.

Returns:

true if this context has been destroyed.

Type
boolean

isDestroying()

Checks whether this context is in the process of being destroyed.

Returns:

true if this context is being destroyed.

Type
boolean

offDestroy(id)

Unregisters a specific callback previously registered with onDestroy.

Parameters:
Name Type Description
id string

The ID of the callback to unregister.


offDetachAll(id)

Unregisters a specific callback previously registered with onDetachAll.

Parameters:
Name Type Description
id string

The ID of the callback to unregister.


onDestroy(callback [, id])

Registers a callback to be executed when this context is destroyed.

Parameters:
Name Type Argument Description
callback function

The callback to register.

id string <optional>

The ID for this callback. If omitted, it will be automatically generated.

Returns:

The ID for the registered callback.

Type
string

onDetachAll(callback [, id])

Registers a callback to be executed when children are being detached from this context.

Parameters:
Name Type Argument Description
callback function

The callback to register.

id string <optional>

The ID for this callback. If omitted, it will be automatically generated.

Returns:

The ID for the registered callback.

Type
string

run(func, args)

Execute a function within this context. This means all nodes created during that execution will be attached to this context or one of its descendents.

Parameters:
Name Type Argument Description
func function

The function to execute.

args * <repeatable>

The arguments to pass to the function.

Returns:

The return value of the the function.

Type
T | undefined

<abstract> setParent(context)

Sets the parent context for this context, or null if it should be un-attached. This will automatically detach from previous parent and attach to the new one.

Parameters:
Name Type Argument Description
context olympe.df.ExecutionContext <nullable>

The parent context, or null.