Class: MiniSignal

MiniSignal

new MiniSignal ()

MiniSignal constructor.

Example
let mySignal = new MiniSignal();
let binding = mySignal.add(onSignal);
mySignal.dispatch('foo', 'bar');
mySignal.detach(binding);

Methods

Register a new listener.

Name Type Default Description
fn function

Callback function.

thisArg Mixed null optional

The context of the callback function.

Returns:
Type Description
MiniSignalBinding The MiniSignalBinding node that was added.

Remove binding object.

Name Type Description
node MiniSignalBinding

The binding node that will be removed.

Returns:
Type Description
MiniSignal The instance on which this method was called.

Detach all listeners.

Returns:
Type Description
MiniSignal The instance on which this method was called.

dispatch ()Boolean

Dispaches a signal to all registered listeners.

Returns:
Type Description
Boolean Indication if we've emitted an event.

handlers (exists)Array.<MiniSignalBinding> | Boolean

Return an array of attached MiniSignalBinding.

Name Type Default Description
exists Boolean false optional

We only need to know if there are handlers.

Returns:
Type Description
Array.<MiniSignalBinding> | Boolean Array of attached MiniSignalBinding or Boolean if called with exists = true

has (node)Boolean

Return true if node is a MiniSignalBinding attached to this MiniSignal

Name Type Description
node MiniSignalBinding

Node to check.

Returns:
Type Description
Boolean True if node is attache to mini-signal

Register a new listener that will be executed only once.

Name Type Default Description
fn function

Callback function.

thisArg Mixed null optional

The context of the callback function.

Returns:
Type Description
MiniSignalBinding The MiniSignalBinding node that was added.