Skip to content

Prhythm/prism-event-bus

Repository files navigation

<prism-event-bus>

Published on webcomponents.org

<prism-event-bus> is a Polymer 2 element provides compact event bus that simplifies communication between elements.

Usage

Register element

// Register element with all event types
PrismEventBus.register(this);
// Register element with scoped types
PrismEventBus.register(this, ['talk', 'walk']);

// Unregister element if destroied or something
PrismEventBus.unregister(this);
// Remove registered event type
PrismEventBus.unregister(this, ['walk']);

Then post event anywhere

// Post immediately
PrismEventBus.post(new CustomEvent('talk', {
    bubbles: false,
    composed: true,
    detail: {
        text: `Hello, World`
    }
}));

// Or post if element will be registered later
PrismEventBus.postDelayed(new CustomEvent('talk', {
    bubbles: false,
    composed: true,
    detail: {
        text: `Hello, World`
    }
}));

Licence

MIT Licence

About

A Polymer web component provides compact event bus that simplifies communication between elements

Resources

License

Stars

Watchers

Forks

Packages

No packages published