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
feat(platform-browser): can config zone/once/passive/capture in event listener.
Close#19878
1. Can't pass `passive`, `capture`, `once` parameters to `addEventListener`.
2. Not easy to config use ngzone or noopzone with HostListener
user need to explicitly call `runOutsideOfAngular` to make sure `eventhandler` run outsideof`ngZone`
```
@HostListener('window:resize', ['$event.target'])
onResize(target: any) {
this.ngZone.runOutsideOfAngular(() => {
console.log('resize triggered');
});
}
```
or call `ngZone.run` explicitly make sure `eventhandler` run into `ngZone`.
```
@HostListener('window:resize', ['$event.target'])
onResize(target: any) {
this.ngZone.run(() => {
console.log('resize triggered');
});
}
```
```
<div (mouseover)="mouseover();"></div>
```
```
mouseover() {
this.ngZone.runOfAngular(() => {
...
});
}
```
3. Can config which `zone` will event handler will run into in `@HostListener` decorator.
4. can config `passive`, `capture`, `once` parameters to `addEventListener`.
- in template, can config those parameter like below.
```
<div (mouseover.capture.once.passive)="mouseover();"></div>
```
even the handler was added not in `ngZone`.
```
<div (mouseover.ngZone)="mouseover();"></div>
```
```
@HostListener('window:resize.ngZone', ['$event.target'])
onResize(target: any) {
console.log('resize triggered');
}
```
- Can config `noopZone` which will guarantee eventhandler run outside of `ngZone`
even the handler was added in `ngZone`.
And it can also work with #20672 to get better performance.
```
<div (mouseover.noopZone)="mouseover();"></div>
```
```
@HostListener('window:resize.noopZone', ['$event.target'])
onResize(target: any) {
console.log('resize triggered');
}
```
Copy file name to clipboardExpand all lines: goldens/size-tracking/integration-payloads.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
"master": {
4
4
"uncompressed": {
5
5
"runtime-es2015": 1485,
6
-
"main-es2015": 141151,
6
+
"main-es2015": 142629,
7
7
"polyfills-es2015": 36571
8
8
}
9
9
}
@@ -21,7 +21,7 @@
21
21
"master": {
22
22
"uncompressed": {
23
23
"runtime-es2015": 1485,
24
-
"main-es2015": 147573,
24
+
"main-es2015": 148562,
25
25
"polyfills-es2015": 36571
26
26
}
27
27
}
@@ -30,7 +30,7 @@
30
30
"master": {
31
31
"uncompressed": {
32
32
"runtime-es2015": 1485,
33
-
"main-es2015": 136168,
33
+
"main-es2015": 137158,
34
34
"polyfills-es2015": 37248
35
35
}
36
36
}
@@ -39,7 +39,7 @@
39
39
"master": {
40
40
"uncompressed": {
41
41
"runtime-es2015": 2289,
42
-
"main-es2015": 245351,
42
+
"main-es2015": 246352,
43
43
"polyfills-es2015": 36938,
44
44
"5-es2015": 751
45
45
}
@@ -49,7 +49,7 @@
49
49
"master": {
50
50
"uncompressed": {
51
51
"runtime-es2015": 2289,
52
-
"main-es2015": 221897,
52
+
"main-es2015": 222792,
53
53
"polyfills-es2015": 36938,
54
54
"5-es2015": 779
55
55
}
@@ -62,7 +62,7 @@
62
62
"bundle": "TODO(i): we should define ngDevMode to false in Closure, but --define only works in the global scope.",
63
63
"bundle": "TODO(i): (FW-2164) TS 3.9 new class shape seems to have broken Closure in big ways. The size went from 169991 to 252338",
64
64
"bundle": "TODO(i): after removal of tsickle from ngc-wrapped / ng_package, we had to switch to SIMPLE optimizations which increased the size from 252338 to 1198917, see PR#37221 and PR#37317 for more info",
0 commit comments