Class: Block

PodJS.Pod# Block

Abstract Base class for block implementations (provided by pods).

A block is an atomic unit of a script.

New types of blocks are added to the system via pods.

Blocks are attached to PodJS.Pod#Resources and can manipulate them.

Blocks also have access to the script and to the environment so they can take global actions.

This is an inner class bound to the Pod superclass that has access to the internal resources of the pod. Pod sub-classes should ensure that all created resources extend from the resource superclass returned by PodJS.Pod#newBlock.

new Block()

Source:

Members

blockInfo :PodJS.BlockInfo

Information about this block
Type:
Source:

blockType :string

The name of the type of block this is an instance of.
Type:
  • string
Source:

context :PodJS.BlockContext

The BlockContext containing a reference to the resource to which it is bound and a reference to the script in which it is executing.
Type:
  • PodJS.BlockContext
Source:

Methods

release()

Release the system resources associated with this block.

Sub-classes can optionally override this method, but must always call the super-class to ensure the proper bookkeeping takes place. Note that blocks will continue to receive ticks until deleted / released.

Source:

reset()

Gets called by the environment when a script is reset, giving the block an opportunity to clear its state.

The default behvaior calls reset() in the blockInfo for the block, if it is present.

Source:

tick() → {undefined|string|number}

Gets called by the environment when this block is active.

Pods are not responsible for calling tick() on their own blocks. That is taken care of by the environment.

The super-class version of tick() calls tick() on the blockInfo, if present. Subclasses can optionally override to perform additional actions on each environment tick.

Sub-classes should be sure to set context.script.yield to true if the resource has completed its tick.

Sub-classes are also responsible for advancing the instruction pointer to the next instruction.

If this is a reporter block, then tick will return a value.

Source:
Returns:
If this is a reporter block, returns the value, else returns undefined.
Type
undefined | string | number