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

[ This description is mirrored from README.md at github.com/Prhythm/prism-event-bus on 2019-05-22 ]

<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

Install

Link to this version
ImportedReleased 20 March 2018Other
Framework Support
Polymer 2.0+
Browser Compatibility
Install with
Release notes - Version 2.0.1

Dependencies

Polymer/polymer#^2.0.0