prism-event-bus
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>
<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
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Dependencies
Polymer/polymer#^2.0.0
- Released
- 2018-03-20
- Maturity
- IMPORTED
- License
- Other
Compatibility
- Framework
- Polymer 2.0+
- Browser
- Browser Independent