feat: add a flag in bootstrap to enable coalesce event to improve performance#30533
feat: add a flag in bootstrap to enable coalesce event to improve performance#30533JiaLiPassion wants to merge 1 commit intoangular:masterfrom
Conversation
b87b7a3 to
b50e1ae
Compare
There was a problem hiding this comment.
I think this is easier to read.
| const ngZoneEventCoalescing = options ? options.ngZoneEventCoalescing : false; | |
| const ngZoneEventCoalescing = (options && options.ngZoneEventCoalescing) || false; |
There was a problem hiding this comment.
| ngZoneOption?: NgZone | 'zone.js' | 'noop', ngZoneEventCoalescing?: boolean): NgZone { | |
| ngZoneOption: NgZone | 'zone.js' | 'noop' | undefiend, ngZoneEventCoalescing: boolean): NgZone { |
There was a problem hiding this comment.
import global from core/src/util
There was a problem hiding this comment.
got it, thanks!
There was a problem hiding this comment.
Just return, I don't think there is a value in canceling it.
There was a problem hiding this comment.
Needs public API docs here.
There was a problem hiding this comment.
can you add docs explaining what this does?
|
Need to run |
|
@mhevery, I fixed several issues, now all tests passed, (expect the case of |
36e5659 to
38a3b0b
Compare
|
Need wait angular/zone.js#1239 to be merged. So the |
e45f1fc to
b0ec7b4
Compare
b0ec7b4 to
1bc95b4
Compare
665c1ae to
0e681c1
Compare
df3dd8c to
5911811
Compare
8f6842d to
8f3b6ba
Compare
|
@matsko, I have updated the PR and now the API will not have any changes, and g3 should be ok, please review, thank you! |
There was a problem hiding this comment.
| * colesced and the change detection will be triggered multiple times. | |
| * coalesced and the change detection will be triggered multiple times. |
There was a problem hiding this comment.
thanks for the review, updated.
There was a problem hiding this comment.
I just stumbled over this PR. Out of curiosity: is it intentional that we introduce a new side-effect global call here?
There was a problem hiding this comment.
you are right, I should not add a side-effect here, I just updated the PR to move the call inside ngZone initialize call.
0743288 to
be89686
Compare
…on to improve performance
be89686 to
90ca4cb
Compare
|
MERGE_ASSISTANCE: Please merge by itself as this is high risk. |
|
Since this change is a high risk (as Misko mentioned), I've started a Global VE presubmit as well (and a Blueprint one). |
|
This was merged to master only. @mhevery @JiaLiPassion is that good or did you also need this in the patch branch? |
|
Should this provide any benefit on server, I mean in case of SSR/Universal? |
There is little chance for DOM events to be triggered on server, unless you manually dispatch them. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
add a new flag in
BootstrapOptionsto enable coalesce event to improve performance.The use case is something like this,
It turns out that as the click event bubbles from the towards the root document it triggers change detection on each listener. This example shows the phenomena in interactive form. Notice that clicking on the will run the change detection twice. Once for the and once for the
So with this PR, we have this new option to let
ngZoneonly runChange Detectiononce in this case.By default, this new
ngZoneEventCoalescingwill befalse, so nothing changed. If this option is being set to true, then only one change detection will be triggered async.