new MiniSignal()
- Source:
Example
let mySignal = new MiniSignal(); let binding = mySignal.add(onSignal); mySignal.dispatch('foo', 'bar'); mySignal.detach(binding);
Methods
-
add(fn [, thisArg])
-
Register a new listener.
Parameters:
Name Type Argument Default Description fn
function Callback function.
thisArg
Mixed <optional>
null The context of the callback function.
- Source:
Returns:
The MiniSignalBinding node that was added.
- Type
- MiniSignalBinding
-
detach(node)
-
Remove binding object.
Parameters:
Name Type Description node
MiniSignalBinding The binding node that will be removed.
- Source:
Returns:
The instance on which this method was called.
- Type
- MiniSignal
-
detachAll()
-
Detach all listeners.
- Source:
Returns:
The instance on which this method was called.
- Type
- MiniSignal
-
dispatch()
-
Dispaches a signal to all registered listeners.
- Source:
Returns:
Indication if we've emitted an event.
- Type
- Boolean
-
handlers( [exists])
-
Return an array of attached MiniSignalBinding.
Parameters:
Name Type Argument Default Description exists
Boolean <optional>
false We only need to know if there are handlers.
- Source:
Returns:
Array of attached MiniSignalBinding or Boolean if called with exists = true
- Type
- Array.<MiniSignalBinding> | Boolean
-
has(node)
-
Return true if node is a MiniSignalBinding attached to this MiniSignal
Parameters:
Name Type Description node
MiniSignalBinding Node to check.
- Source:
Returns:
True if node is attache to mini-signal
- Type
- Boolean
-
once(fn [, thisArg])
-
Register a new listener that will be executed only once.
Parameters:
Name Type Argument Default Description fn
function Callback function.
thisArg
Mixed <optional>
null The context of the callback function.
- Source:
Returns:
The MiniSignalBinding node that was added.
- Type
- MiniSignalBinding