platypush/platypush/backend/http/webapp/src/bus.js
Fabio Manganiello 3923a09831
- Expose methods on the bus module to publish/subscribe to notifications and entity updates
- Removed some redundant `pass` statements in Z-Wave derived event classes
2023-01-21 16:56:27 +01:00

22 lines
382 B
JavaScript

import mitt from 'mitt'
const bus = mitt()
bus.publishEntity = (entity) => {
bus.emit('entity-update', entity)
}
bus.onEntity = (callback) => {
bus.on('entity-update', callback)
}
bus.publishNotification = (notification) => {
bus.emit('notification-create', notification)
}
bus.onNotification = (callback) => {
bus.on('notification-create', callback)
}
export { bus }