Skip to content

Commit

Permalink
patch: simplify bus
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Feb 17, 2022
1 parent ebd8188 commit f8a934c
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions packages/shared/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ export function createBus(): {

return {
emit(event: string, data: any) {
if (!listeners[event]) {
return;
}

listeners[event].forEach(listener => {
listener(data);
(listeners[event] || []).forEach(handler => {
handler(data);
});
},

on(event: string, handler: (...args: any[]) => void): { off: () => void } {
if (!listeners[event]) {
listeners[event] = [];
}

listeners[event].push(handler);
listeners[event] = (listeners[event] || []).concat(handler);

return {
off() {
Expand Down

1 comment on commit f8a934c

@vercel
Copy link

@vercel vercel bot commented on f8a934c Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-next.vercel.app
vest-next-ealush.vercel.app

Please sign in to comment.