Skip to content

Commit cea049d

Browse files
readme updated
1 parent a5cb93c commit cea049d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

readme.md

+26
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,29 @@ In this example:
106106
# Snippets
107107

108108
## How to deal with dark/light mode
109+
110+
## EventTarget as a global storage
111+
112+
Why to use it?
113+
114+
- A way of communication between components
115+
- Source of the truth
116+
- Implement subscriber/listener pattern
117+
118+
Interface
119+
120+
```js
121+
interface EventTarget {
122+
addEventListener(
123+
type: string,
124+
callback: EventListenerOrEventListenerObject | null,
125+
options?: AddEventListenerOptions | boolean
126+
): void;
127+
dispatchEvent(event: Event): boolean;
128+
removeEventListener(
129+
type: string,
130+
callback: EventListenerOrEventListenerObject | null,
131+
options?: EventListenerOptions | boolean
132+
): void;
133+
}
134+
```

0 commit comments

Comments
 (0)