xref: /openbmc/webui-vue/src/eventBus.js (revision d36ac8a8be8636ddd0e64ce005d507b21bcdeb00)
1import mitt from 'mitt';
2
3const emitter = mitt();
4
5function once(event, handler) {
6  const wrapper = (...args) => {
7    emitter.off(event, wrapper);
8    handler(...args);
9  };
10  emitter.on(event, wrapper);
11}
12
13export default {
14  // Vue 2-style alias
15  $on: emitter.on,
16  $off: emitter.off,
17  $emit: emitter.emit,
18  $once: once,
19  // Plain methods used by PS4 branch
20  on: emitter.on,
21  off: emitter.off,
22  emit: emitter.emit,
23  once,
24};
25