Component(name, type, eventClass) → {Component}

A component that implements some functionality and communicates with other components. Used as a base class for various parts of the system that will interact through events.

new Component(name, type, eventClass) → {Component}

constructor

Parameters:
Name Type Description
name string

The name of the module.

type string

The type of the module

eventClass EventBase

The class to use for events for this component

Returns:
Component -

The Object that was created

Properties:
Name Type Description
name string

The name of the component

string type

The type of the component

eventClass EventBase

A constructor function for the class of events used by the component

Members

static list

A global list of all components that have been registered. Value is a Map of Components. Map keys are the component name.

Methods

static clearList()

Clears the global list of registered Components. Mostly used for testing.

static get(name) → {Component}

Look up a Component using its name

Parameters:
Name Type Description
name string

The name of the Component passed in at registration time

Returns:
Component -

The Component with the corresponding name or undefined if none was found

static register(comp)

Registers a component on the global component list

Parameters:
Name Type Description
comp Component

The component to be registered

sendEvent(type, data)

Emits an event using the specified eventClass

Parameters:
Name Type Description
type string

The event type to emit

data *

The data to emit