blob: 506510c2259222659f6945718e15470c4f4d484c [file] [log] [blame]
jason westoverd36ac8a2025-11-03 20:58:59 -06001import mitt from 'mitt';
Konstantinfb6c6de2023-06-14 17:23:14 +03002
jason westoverd36ac8a2025-11-03 20:58:59 -06003const emitter = mitt();
Konstantinfb6c6de2023-06-14 17:23:14 +03004
jason westoverd36ac8a2025-11-03 20:58:59 -06005function 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};