Class: TemplateInstance

lib/core/renderer/program/TemplateInstance.TemplateInstance(program, host, localsopt)

A mounted render program.

Constructor

new TemplateInstance(program, host, localsopt)

Parameters:
Name Type Attributes Description
program object

The render program to instantiate.

host object

The owner.

Properties
Name Type Attributes Description
evaluate function

Evaluates an expression.

onSuspend function <optional>

Called when a binding throws a Promise, so the owner can suspend.

jobId number <optional>

Orders this instance's jobs against other components in a flush, so a parent still updates before its children.

onRendered function <optional>

Called when a binding has re-applied, so the owner can fire its once-per-flush lifecycle hooks.

onChildProps function <optional>

Called when a prop for a child component changed value.

onBeforeRender function <optional>

Called before the first binding of a flush applies, so the owner can fire onBeforeUpdate.

locals object | null <optional>

Names this instance binds that its component does not declare, such as a loop's item and index.

Source:

Members

bindings :Array:.<object:>

One entry per op, holding its watcher, its job and whatever state that op kind needs to remember between runs.

Type:
  • Array:.<object:>
Source:

blocks :Array:.<object:>

Blocks this program's control flow can render.

Read from the root program rather than from a block, because a block is {html, ops, ...} and has no table of its own: nesting is expressed by index into one table for the whole component.

Type:
  • Array:.<object:>
Source:

compiled :CompiledTemplate

Type:
  • CompiledTemplate
Source:

disposed :boolean

Type:
  • boolean
Source:

elements :Array:.<Element:>

Type:
  • Array:.<Element:>
Source:

fragment :DocumentFragment|null

Type:
  • DocumentFragment | null
Source:

host :object

Type:
  • object
Source:

locals :object|null

Names this instance binds that its component does not declare -- a loop's item and index. Null for a component's root instance.

Held as one mutable object per instance so a reused list row can be given a new value in place, waking only the bindings that read it, instead of being rebuilt.

Type:
  • object | null
Source:

program :object

Type:
  • object
Source:

texts :Array:.<Text:>

Type:
  • Array:.<Text:>
Source:

usable

Whether the program could be prepared for this host environment.

Source:

Methods

create() → {DocumentFragment|null}

Clones the skeleton and runs every binding once.

The bindings run while the tree is still detached, so the first paint sees finished markup rather than a skeleton that fills in.

Source:
Returns:

The populated fragment, ready to insert.

Type
DocumentFragment | null

dispose()

Releases every effect and forgets every node reference.

Called on unmount. Without it each binding's watcher stays in the dependency sets of the state it read, which keeps the component, its DOM and its scope alive for as long as that state exists.

Source:

refresh()

Re-runs every binding, whatever its dependencies say.

Needed when something outside the reactive graph changes what an expression would return -- new props, a swapped bridge, a resource that settled. The fine-grained path handles state; this handles everything else.

Source: