Event Executor (String)
The Event Executor (src) dispatches a RingaEvent
on the parent Controller's Bus (or DOM node) and waits for it to complete.
controller.addListener('subEvent', () => {console.log('Feeling a little triggered right now...')});
controller.addListener('event', ['subEvent']);
By default, providing a string
to a executor Array will create an EventExecutor
instance that creates and dispatches a new RingaEvent
every time it is executed. All details on the current RingaEvent
will be passed to the new event that is dispatched. The current Thread
will wait until anything that the dispatched RingaEvent
is done before continuing.
You may want to add new properties (or override current ones) on the RingaEvent::detail
, or adjust whether it is bubbling etc. To do so, you can use the event()
wrapper provided by Ringa:
Syntax:
event(eventType, detail, bus, requireCatch = false, bubbles = true, cancellable = true, event = undefined)
- eventType: the event type to dispatch
- detail: the detail Object (is shallow merged into the current event's detail)
- bus: the bus to dispatch on (defaults to the one the Controller is attached to)
- requireCatch: when true, a warning is displayed if the Event is not caught.
- bubbles: turns on event bubbling for the event that is dispatched.
- cancellable: not used yet
-
event: if another event triggered this one (e.g. a DOM event like
'click'
) then you would provide that here.
import {event} from 'ringa';
controller.addListener('subEvent', (message) => {console.log(message)});
controller.addListener('event', [
event('subEvent', {message: 'So, I'm gonna need you to come in on Saturday...'})
]);