Adding a few files which are currently not used before a huge refactoring...
This commit is contained in:
1 parent
ce074b5d22
commit
ed951208e8
3 files changed
+87
No files matched your search
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
*
|
||||
* See https://www.pluralsight.com/guides/how-to-communicate-between-independent-components-in-reactjs (and many similar pages)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const eventBus = {
|
||||
on(event: string, callback: any) {
|
||||
// ...
|
||||
document.addEventListener(event, (e) => callback(e));
|
||||
},
|
||||
|
||||
dispatch(event: string, data: any) {
|
||||
// ...
|
||||
document.dispatchEvent(new CustomEvent(event, { detail: data }));
|
||||
},
|
||||
|
||||
remove(event: string, callback: (e: Event) => void) {
|
||||
// ...
|
||||
document.removeEventListener(event, callback);
|
||||
},
|
||||
};
|
||||
|
||||
export default eventBus;
|
||||
Reference in new issue
Block a user