Class

RezView

RezView()

Constructor

# new RezView()

The main view controller that manages rendering and DOM transformations.

RezView is responsible for:

  • Managing the layout hierarchy and content blocks
  • Rendering HTML into the container element
  • Applying transformers to set up event handlers and bindings
  • Tracking two-way data bindings between form elements and game state

The view uses a layout stack to support nested layouts during complex rendering scenarios. Bindings are cleared and re-established on each render cycle.

View Source rez_view.js, line 1377

Example
// Create a view with a stack layout
const layout = new RezStackLayout("scene", sceneElement);
const view = new RezView("game-container", eventReceiver, layout);

// Add content and render
view.addLayoutContent(new RezBlock("card", cardElement));
view.update();

Members

Map.<string, function()>

# bindings

Map of registered bindings (keyed by "id.attr").

View Source rez_view.js, line 1499

Element

# container

The DOM container element for this view.

View Source rez_view.js, line 1443

RezLayout

# layout

The current root layout.

View Source rez_view.js, line 1451

Array.<RezLayout>

# layoutStack

The stack of pushed layouts.

View Source rez_view.js, line 1463

Object

# receiver

The event receiver for this view.

View Source rez_view.js, line 1507

Array.<RezTransformer>

# transformers

The transformers applied after each render.

View Source rez_view.js, line 1515

Methods

# addLayoutContent(content)

Adds content to the current layout.

Parameters:
Name Type Description
content RezBlock

The content block to add

View Source rez_view.js, line 1491

# clearBindings()

Clears all registered bindings.

Called at the start of each render cycle since bindings are re-established by transformers.

View Source rez_view.js, line 1609

# copy() → {RezView}

Creates a copy of this view with copied layouts.

Bindings are not copied as they are cleared on each render.

View Source rez_view.js, line 1631

A new view with copied state

RezView

# defaultTransformers() → {Array.<RezTransformer>}

Creates the default set of transformers.

Default transformers handle:

  • Click events ([data-event])
  • Card block references
  • Form submissions
  • Data bindings (rez-bind)
  • Live inputs (rez-live)
  • Enter key handling

View Source rez_view.js, line 1544

Array of default transformers

Array.<RezTransformer>

# hasBinding(binding_id, binding_attr) → {boolean}

Checks if a binding is registered for a given element and attribute.

Parameters:
Name Type Description
binding_id string

The element ID

binding_attr string

The attribute name

View Source rez_view.js, line 1571

True if binding exists

boolean

# popLayout()

Pops the current layout and restores the previous one.

View Source rez_view.js, line 1482

# pushLayout(layout)

Pushes a new layout onto the stack, making it the current layout.

Use this when entering a nested layout context. Pop when exiting.

Parameters:
Name Type Description
layout RezLayout

The layout to push

View Source rez_view.js, line 1474

# registerBinding(binding_id, binding_attr, callback)

Registers a callback for updating a bound control when data changes.

Parameters:
Name Type Description
binding_id string

The element ID

binding_attr string

The attribute name

callback function

Function called with new value when data changes

View Source rez_view.js, line 1582

# render()

Renders the layout HTML into the container.

Note: Event listeners added by transformers are automatically cleaned up when innerHTML is replaced - no explicit cleanup needed. The DOM elements holding the listeners are destroyed, allowing garbage collection.

View Source rez_view.js, line 1526

# transform()

Applies all transformers to the rendered DOM.

View Source rez_view.js, line 1558

# update()

Performs a complete view update: clear bindings, render, and transform.

This is the main method to call when the view needs to refresh.

View Source rez_view.js, line 1618

# updateBoundControls(binding_id, binding_attr, value)

Updates bound form controls when the underlying data changes.

Called by game elements when their attributes change to keep the UI in sync.

Parameters:
Name Type Description
binding_id string

The element ID

binding_attr string

The attribute name

value *

The new value

View Source rez_view.js, line 1596

# static constructor(container_id, receiver, layout, transformersopt)

Creates a new RezView.

Parameters:
Name Type Attributes Description
container_id string

ID of the DOM container element

receiver Object

Event receiver for handling user interactions

layout RezLayout

The root layout for the view

transformers Array.<RezTransformer> <optional>

Custom transformers (uses defaults if not provided)

View Source rez_view.js, line 1415

If container element not found

Error