Component(attributesopt)

new Component(attributesopt)

Abstract base class.

Parameters:
Name Type Attributes Description
attributes object | undefined <optional>

The instance attributes.

Source:

Members

events :object

The events attribute.

Type:
  • object
Source:

name :string

Get the name attribute.

Type:
  • string
Source:

Methods

(static) make(…args) → {*}

Factor method to static instantiate new instances. Useful for writing clean expressive syntax with chained methods.

Parameters:
Name Type Attributes Description
args * <repeatable>

The callback arguments.

Source:
Returns:
  • The new component instance.
Type
*

callback(fn) → {*}

Helper method to execute the callback() function.

Parameters:
Name Type Description
fn function

The callback function.

Source:
Returns:
  • Returns the executed callback function.
Type
*

emit(key) → {Component}

Emit an event.

Parameters:
Name Type Description
key string

The event id/key.

Source:
Returns:
  • Returns this instance.
Type
Component

getAttribute(key) → {*}

Get an attribute. Returns null if no attribute is defined.

Parameters:
Name Type Description
key string

The attribute name.

Source:
Returns:
  • The attribute value.
Type
*

getAttributes() → {object}

Get all the atttributes for this instance.

Source:
Returns:
  • The attribute dictionary.
Type
object

getPublicAttributes() → {object}

Get only public the atttributes for this instance. Omits any attribute that starts with $, which is used internally.

Source:
Returns:
  • The attribute dictionary.
Type
object

off(key, fn) → {Component}

Stop listening to an event.

Parameters:
Name Type Description
key string

The event id/key.

fn function | undefined

The listener callback function. If no function is defined, all events with the specified id/key will be removed. Otherwise, only the event listeners matching the id/key AND callback will be removed.

Source:
Returns:
  • Returns this instance.
Type
Component

on(key, fn, onceopt) → {Component}

Start listening to an event.

Parameters:
Name Type Attributes Default Description
key string

The event id/key.

fn function

The listener callback function.

once boolean <optional>
false

Should the event handler be fired a single time.

Source:
Returns:
  • Returns this instance.
Type
Component

once(key, fn) → {Component}

Listen to an event only one time.

Parameters:
Name Type Description
key string

The event id/key.

fn function

The listener callback function.

Source:
Returns:
  • Returns this instance.
Type
Component

setAttribute(key, value) → {void}

Set an attribute key and value.

Parameters:
Name Type Description
key string

The attribute name.

value *

The attribute value.

Source:
Returns:
Type
void

setAttributes(values) → {void}

Set an attributes by object of key/value pairs.

Parameters:
Name Type Description
values object

The object dictionary.

Source:
Returns:
Type
void