Signal

Signal

A signal instance that returns the current value when called as a function.
Source:

Members

(readonly) length :number

The number of listeners added
Source:
Type:
  • number

state

The current state
Source:

Methods

add(listener, onceopt, immediateopt) → {Slot}

Add listener to signal
Source:
Parameters:
Name Type Attributes Default Description
listener function The listener to be executed when the signal dispatches
once boolean <optional>
false Executes the listener only once when set to true
immediate boolean <optional>
false Executes the listener immediately with current state
Returns:
Type:
Slot

addOnce(listener) → {Slot}

Add listener to signal
Source:
Parameters:
Name Type Description
listener function The listener to be executed when the signal dispatches
Returns:
Type:
Slot

clear() → {Signal}

Remove all signal listeners
Source:
Returns:
Type:
Signal

dispatch(values) → {Signal}

Dispatch the signal The `values` parameter can be empty, a single value, or an array of values. The listener is executed with these values as parameters.
Source:
Parameters:
Name Type Description
values Array.<any>
Returns:
Type:
Signal

has() → {boolean}

Test if listener was added
Source:
Returns:
Type:
boolean

toString() → {string}

The current state as a string
Source:
Returns:
Type:
string