Created
November 23, 2023 08:47
-
-
Save harish2704/2cff29440d629a2d21002b3cbb7063bf to your computer and use it in GitHub Desktop.
Revisions
-
harish2704 created this gist
Nov 23, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ // Source: https://itnext.io/handling-data-with-web-components-9e7e4a452e6e class EventBus { constructor() { this._bus = document.createElement('div'); } register(event, callback) { this._bus.addEventListener(event, callback); } remove(event, callback) { this._bus.removeEventListener(event, callback); } fire(event, detail = {}) { this._bus.dispatchEvent(new CustomEvent(event, { detail })); } }