frontend/.pnpm-store/v3/files/21/6e5eae711b2430d4b33cdfe25402f21a9a6a8fb396106735069b0812318358516b7d58c3f0197e473d9035ce7e4b25425837ce9c37c414b4e9f97a6f3978cd

16 lines
467 B
Plaintext

export default function proxyEvents(from, to, events) {
const eventFunctions = {};
for (const event of events) {
const eventFunction = (...args) => {
to.emit(event, ...args);
};
eventFunctions[event] = eventFunction;
from.on(event, eventFunction);
}
return () => {
for (const [event, eventFunction] of Object.entries(eventFunctions)) {
from.off(event, eventFunction);
}
};
}