Component

Component

A component is simply a structured set of data defined by a type.
Members

Fields & Properties
Methods

Constructor

new Component(typenon-null, stateopt)

Mixes In:
Parameters
Name Type Attributes Description
type string The component type.
state * <optional>
The initial state.

Members

(private) state :*

The data contained in the component.

(private, readonly) type :string

A literal that identifies the type of data in the component.

Methods

getState(pathopt) → {*}

Get data from the component state. Returns the entire state if no path is specified.
Parameters
Name Type Attributes Description
path string <optional>
The path to a value in the state.
Throws
TypeError
Will throw this error if the path argument is not a string.
ReferenceError
Will throw this error if invoked after being disposed.
Returns
The requested value from the state.
Type
*

getType() → {string}

Get the component type.
Throws
ReferenceError
Will throw this error if invoked after being disposed.
Returns
The component type.
Type
string

setState(pathopt, data) → {Component}

Set data into the component state. Replaces the entire state if no path is specified.
Parameters
Name Type Attributes Description
path string <optional>
The path in the state where to set the data.
data * The data to set.
Fires:
Throws
TypeError
Will throw this error if the path argument is not a string.
ReferenceError
Will throw this error if invoked after being disposed.
Returns
Itself
Type
Component

Events

component:change

A change event occurs when the state of a component changes.
Parameters
Name Type Description
component Component The component that changed.
newState * The new value of the component.
oldState * The old value of the component.

component:dispose

A dispose event occurs when a component is being disposed.
Parameters
Name Type Description
component Component The component that is being disposed.
Listens to Events:
  • Component#Component: change