You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libs/cdk/zone-less/docs/README.md
+78-15Lines changed: 78 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -5,31 +5,62 @@ A demo application is available on [GitHub](https://github.com/BioPhoton/rx-angu
5
5
6
6
# Motivation
7
7
8
-
# Available Approaches
8
+
By default, Angular or better say zone.js patches most of the asynchronouse API's of the Browser.
9
+
This adds additional overhead on those API's and even more important, this leads to un-nessecary renderings of the Angular component tree, also known as overredering.
9
10
10
-
-`ngZone#runOutsideZone`
11
-
- RxAngular CDK/Zone-Less
11
+
Until now developers where only able to either disable zone.js completely or wrapping another logic around the patched APIs to avoid change detection calls.
12
+
This of course requires to inject another service and also makes your code more cluttery and slow.
12
13
13
-
**The Benefits of RxAngular**
14
+
The zone-less package helps out here.
15
+
It provides a general method to access the unpatched version of an API and also ships a set of commonly used APIs of the Browser as well as RxJS.
16
+
All those APIs are fully independent of zone.js and NgZone (which is normally used to run things outside Angular).
14
17
15
-
- ✅
16
18
17
-
## `ngZone#runOutsideZone`
19
+
#The Benefits
18
20
19
-
**Event Bubbling of smae event on multiple elements**
21
+
- ✅ Fastest option possible
22
+
- ✅ Drop-in replacement for navive APIs
23
+
- ✅ Drop-in replacement for RxJS functions
24
+
- ✅ No need for `ngZone#runOutsideZone`
20
25
21
-
```html
22
-
<div(click)="doStuff()">
23
-
<button(click)="doStuff()">click</button>
24
-
</div>
25
-
```
26
+
# RxAngular CDK/Zone-Less
27
+
28
+
The way how zone.js works is, it patches all relevant async APIs of the Browser. This happens early on as zone.js is treated as polyfill.
All original logic of the patched API's is stored under a symbol in `window`. You can check that by logging for example the following value: `console.log(window.__zone_symbol__setTimeout)`.
33
+
This will print the original unpatched API to the Brwosers console.
34
+
35
+
Internally the symbols and in turn the unpatched API's is what the zone-less package is using.
36
+
The essential method used to get hold of the unpatched APIs is called `getZoneUnPatchedApi`. It takes a target i.e. `window` and a name of the method we want to retreive the unpatched version of.
0 commit comments