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.
argtypedescription
signalsstring ArraySingle signal identifier or an array of signal identifiers.
callbackfunctionCallback to subscribe to signal list(s).

emit

du.signals.emit(signal[, args])

Emits a signal and calls all subscribed callbacks.
argtypedescription
signalstringIdentifier of the signal to emit.
argsobjectArguments to pass to the triggered callbacks. optional