Broadcast System - OwlTechnology/ComfyJs GitHub Wiki
The framework exposes an API for broadcasting events throughout the DOM. This is similar to the listener pattern, but without knowing exactly what is broadcasting. This includes automatic broadcast scoping.
$broadcast(eventName: string, payload: object?)
Broadcasts an event. The eventName
must be formatted in the following way: it may only contain alphanumeric characters excluding space or other whitespace characters. If you want to specify scope, use a .
.
An example event name would be foo.bar.baz
. This means that the baz
event you broadcasted is in the foo.bar
context, so anything listening to foo
, foo.bar
, or foo.bar.baz
will receive this event and its payload.
$on(eventName: string, callback: function)
Receives a broadcasted event by its event name (see above for event-name syntax and scoping). The callback
function specified will be called when an event in the right scope specified is fired using the $broadcast
method.