du.signals
Module for managing event subscriptions and emissions.Callbacks can be subscribed to signals and when an event of that signal is triggered, all subscribed callbacks are called.
subscribe
du.signals.subscribe(signals, callback)
Subscribes a callback to one or multiple signal lists. If the signal does not exists yet, it is created as well.
| arg | type | description |
|---|---|---|
| signals | string Array | Single signal identifier or an array of signal identifiers. |
| callback | function | Callback to subscribe to signal list(s). |
emit
du.signals.emit(signal[, args])
Emits a signal and calls all subscribed callbacks.
| arg | type | description |
|---|---|---|
| signal | string | Identifier of the signal to emit. |
| args | object | Arguments to pass to the triggered callbacks. optional |