Created
November 26, 2024 17:46
-
-
Save ruanvalente/47358e3b1d215f7d596da824861a232e to your computer and use it in GitHub Desktop.
Revisions
-
ruanvalente revised this gist
Nov 26, 2024 . No changes.There are no files selected for viewing
-
ruanvalente created this gist
Nov 26, 2024 .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,14 @@ type EmitFunction<T> = (eventType: string, detail: T) => void; const useEmit = <T,>(): EmitFunction<T> => { const emit: EmitFunction<T> = (eventType: string, detail: T) => { const customEvent = new CustomEvent(eventType, { detail }) window.dispatchEvent(customEvent) } return emit } export default useEmit