Usage in components

Once you have created your events instance, the withEventBus function extends a component and makes working with an event bus easier in component methods.

Subscriptions based on lifecycle hooks will be automatically handled within the component.
You need to provide the initial topic subscription (use the created or mounted lifecycle hook) and then once established, subscriptions
will be handled automatically when the component fires the removed or updated lifecycle hook.

See extending components for more on the withEventBus function.

import { createCustomElement, createEventBus, withEventBus } from ''
import { html, renderer } from ''

const eventBus = createEventBus()

// A new component
withEventBus(eventBus, {
handleEvent (data) {
/* handle event here */
mounted () {'my-event', this.handleEvent)
render () {
/* handle render here */