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

Add ability to configure NgZone in bootstrapApplication #49557

Closed
wants to merge 4 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Mar 23, 2023

see individual commits

@atscott atscott added area: core Issues related to the framework runtime target: minor This PR is targeted for the next minor release labels Mar 23, 2023
@ngbot ngbot bot added this to the Backlog milestone Mar 23, 2023
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 23, 2023
…oviders

This commit updates the `bootstrapApplication` method to get the
`NgZone` instance from DI. This will allow a future change to enable
developers to configure `NgZone` in DI rather than adding the options to
the top level like in `bootstrapModuleFactory` (which is done in order
to get the NgZone instance without going through DI).
This commit adds a provider function that allows developers to configure
the `NgZone` instance for the application. In the future, this provider
will be used for applications to specifically opt-in to change detection
powered by ZoneJS rather than it being provided by default.

This API does _not_ specifically provide support for developers to define their own
`NgZone` implementation or opt in to `NoopNgZone` directly. Both of
these are possible today, but are effectively unsupported (applications
that use these are left to their own devices to run change detection at
the appropriate times). That said, developers can still use DI in
`bootstrapApplication` to provide an `NgZone` implementation instead,
it's just not specifically available in the
`provideZoneChangeDetection` function.
goldens/public-api/core/index.md Outdated Show resolved Hide resolved
@pullapprove pullapprove bot requested a review from alxhub March 30, 2023 21:11
packages/core/src/application_ref.ts Show resolved Hide resolved
packages/core/src/application_ref.ts Outdated Show resolved Hide resolved
packages/core/src/application_ref.ts Outdated Show resolved Hide resolved
packages/core/src/application_ref.ts Outdated Show resolved Hide resolved
packages/core/src/application_ref.ts Outdated Show resolved Hide resolved
Comment on lines +517 to +521
if ((typeof ngDevMode === 'undefined' || ngDevMode) &&
moduleRef.injector.get(PROVIDED_NG_ZONE, null) !== null) {
throw new RuntimeError(
RuntimeErrorCode.PROVIDER_IN_WRONG_CONTEXT,
'`bootstrapModule` does not support `provideZoneChangeDetection`. Use `BootstrapOptions` instead.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

@pullapprove pullapprove bot requested a review from dylhunn March 30, 2023 23:16
@atscott atscott modified the milestones: Backlog, v16-candidates Mar 30, 2023
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Mar 31, 2023
@ngbot
Copy link

ngbot bot commented Mar 31, 2023

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing
    pending status "pullapprove" is pending
    pending 3 pending code reviews

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@atscott atscott added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Mar 31, 2023
@atscott
Copy link
Contributor Author

atscott commented Mar 31, 2023

caretaker: TAP failures are pre-existing

@dylhunn
Copy link
Contributor

dylhunn commented Mar 31, 2023

This PR was merged into the repository by commit d7d6514.

@dylhunn dylhunn closed this in 58c1faf Mar 31, 2023
dylhunn pushed a commit that referenced this pull request Mar 31, 2023
…n` (#49557)

This commit adds a provider function that allows developers to configure
the `NgZone` instance for the application. In the future, this provider
will be used for applications to specifically opt-in to change detection
powered by ZoneJS rather than it being provided by default.

This API does _not_ specifically provide support for developers to define their own
`NgZone` implementation or opt in to `NoopNgZone` directly. Both of
these are possible today, but are effectively unsupported (applications
that use these are left to their own devices to run change detection at
the appropriate times). That said, developers can still use DI in
`bootstrapApplication` to provide an `NgZone` implementation instead,
it's just not specifically available in the
`provideZoneChangeDetection` function.

PR Close #49557
@dylhunn
Copy link
Contributor

dylhunn commented Mar 31, 2023

Hooray!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants