Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component): use global render strategy in zone-less mode #3379

Conversation

markostanimirovic
Copy link
Member

@markostanimirovic markostanimirovic commented Apr 14, 2022

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #3342

What is the new behavior?

@ngrx/component uses a global rendering strategy in zone-less mode.

Does this PR introduce a breaking change?

[x] Yes
[ ] No

BREAKING CHANGES:

The native local rendering strategy is replaced by global in zone-less mode for better performance.

BEFORE:

The change detection is triggered via `changeDetectorRef.detectChanges` in zone-less mode.

AFTER:

The change detection is triggered via `ɵmarkDirty` in zone-less mode.

@netlify
Copy link

netlify bot commented Apr 14, 2022

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 737f129
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/625767499f77770008d5ae28
😎 Deploy Preview https://deploy-preview-3379--ngrx-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

BREAKING CHANGES:

The native local rendering strategy is replaced by global
in zone-less mode for better performance.

BEFORE:

The change detection is triggered via `changeDetectorRef.detectChanges`
in zone-less mode.

AFTER:

The change detection is triggered via `ɵmarkDirty` in zone-less mode.
@markostanimirovic markostanimirovic force-pushed the feat/component/mark-dirty-zoneless branch from 737f129 to cd71bba Compare May 19, 2022 11:59
@brandonroberts brandonroberts merged commit f233dae into ngrx:master May 23, 2022
@LayZeeDK
Copy link
Contributor

@markostanimirovic
How confident are you that ɵmarkDirty won't suddenly be removed or changed? It's a function internal to Angular and intentionally not part of its public API surface.

@markostanimirovic
Copy link
Member Author

@LayZeeDK

The previous way of triggering CD in zone-less mode via cdr.detectChanges without coalescing was inefficient and it had to be changed. Because we use the "global" rendering strategy in zone-full mode, we agreed to use the same strategy in zone-less mode.

I chose ɵmarkDirty because it already implements what we need in the zone-less mode for the "global" rendering strategy - it marks the passed component as dirty, schedules a tick, and coalesces multiple ɵmarkDirty calls into a single CD run.

I'm aware that ɵmarkDirty can be changed/removed at any moment. However, it has been part of the "ɵpublic" API for more than 2 years. If Angular team decides to remove it, we'll implement a custom solution for scheduling/coalescing tick calls in zone-less mode.

@LayZeeDK
Copy link
Contributor

LayZeeDK commented Jul 5, 2022

@markostanimirovic
angular/angular#46709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@ngrx/component: Use "global" rendering strategy in zoneless mode
4 participants