From cea049d94fafa909c581009cb0c594a8ef69954d Mon Sep 17 00:00:00 2001 From: Serik Date: Thu, 4 Jul 2024 01:05:37 +0500 Subject: [PATCH] readme updated --- readme.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/readme.md b/readme.md index dde04f5..c164225 100644 --- a/readme.md +++ b/readme.md @@ -106,3 +106,29 @@ In this example: # Snippets ## How to deal with dark/light mode + +## EventTarget as a global storage + +Why to use it? + +- A way of communication between components +- Source of the truth +- Implement subscriber/listener pattern + +Interface + +```js +interface EventTarget { + addEventListener( + type: string, + callback: EventListenerOrEventListenerObject | null, + options?: AddEventListenerOptions | boolean + ): void; + dispatchEvent(event: Event): boolean; + removeEventListener( + type: string, + callback: EventListenerOrEventListenerObject | null, + options?: EventListenerOptions | boolean + ): void; +} +```