diff --git a/packages/core/src/application/create_application.ts b/packages/core/src/application/create_application.ts index c6f8e7de7bd313..108369478f7d43 100644 --- a/packages/core/src/application/create_application.ts +++ b/packages/core/src/application/create_application.ts @@ -26,6 +26,8 @@ import {NgZone} from '../zone/ng_zone'; import {ApplicationInitStatus} from './application_init'; import {_callAndReportToErrorHandler, ApplicationRef} from './application_ref'; +import {ChangeDetectionScheduler} from '../change_detection/scheduling/zoneless_scheduling'; +import {ChangeDetectionSchedulerImpl} from '../change_detection/scheduling/zoneless_scheduling_impl'; /** * Internal create application API that implements the core application creation logic and optional @@ -55,7 +57,11 @@ export function internalCreateApplication(config: { // Create root application injector based on a set of providers configured at the platform // bootstrap level as well as providers passed to the bootstrap call by a user. - const allAppProviders = [internalProvideZoneChangeDetection({}), ...(appProviders || [])]; + const allAppProviders = [ + internalProvideZoneChangeDetection({}), + {provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl}, + ...(appProviders || []), + ]; const adapter = new EnvironmentNgModuleRefAdapter({ providers: allAppProviders, parent: platformInjector as EnvironmentInjector, diff --git a/packages/core/src/change_detection/scheduling/flags.ts b/packages/core/src/change_detection/scheduling/flags.ts deleted file mode 100644 index 2bbd6727c441c0..00000000000000 --- a/packages/core/src/change_detection/scheduling/flags.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -/** Flag to enable/disable the zoneless scheduler as default provider with zone scheduling. */ -export const alwaysProvideZonelessScheduler = true; diff --git a/packages/core/src/change_detection/scheduling/ng_zone_scheduling.ts b/packages/core/src/change_detection/scheduling/ng_zone_scheduling.ts index 44a93d758a0b05..0ecfa54e74678e 100644 --- a/packages/core/src/change_detection/scheduling/ng_zone_scheduling.ts +++ b/packages/core/src/change_detection/scheduling/ng_zone_scheduling.ts @@ -25,20 +25,13 @@ import {performanceMarkFeature} from '../../util/performance'; import {NgZone} from '../../zone'; import {InternalNgZoneOptions} from '../../zone/ng_zone'; -import {alwaysProvideZonelessScheduler} from './flags'; -import { - ChangeDetectionScheduler, - ZONELESS_ENABLED, - ZONELESS_SCHEDULER_DISABLED, -} from './zoneless_scheduling'; -import {ChangeDetectionSchedulerImpl} from './zoneless_scheduling_impl'; +import {ChangeDetectionScheduler, ZONELESS_SCHEDULER_DISABLED} from './zoneless_scheduling'; @Injectable({providedIn: 'root'}) export class NgZoneChangeDetectionScheduler { private readonly zone = inject(NgZone); private readonly changeDetectionScheduler = inject(ChangeDetectionScheduler, {optional: true}); private readonly applicationRef = inject(ApplicationRef); - private readonly zonelessEnabled = inject(ZONELESS_ENABLED); private _onMicrotaskEmptySubscription?: Subscription; @@ -119,11 +112,6 @@ export function internalProvideZoneChangeDetection({ // Always disable scheduler whenever explicitly disabled, even if another place called // `provideZoneChangeDetection` without the 'ignore' option. ignoreChangesOutsideZone === true ? {provide: ZONELESS_SCHEDULER_DISABLED, useValue: true} : [], - // TODO(atscott): This should move to the same places that zone change detection is provided by - // default instead of being in the zone scheduling providers. - alwaysProvideZonelessScheduler || ignoreChangesOutsideZone === false - ? {provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl} - : [], ]; } diff --git a/packages/core/src/core_private_export.ts b/packages/core/src/core_private_export.ts index 411c94a8d95790..532096dd50ed9d 100644 --- a/packages/core/src/core_private_export.ts +++ b/packages/core/src/core_private_export.ts @@ -22,6 +22,7 @@ export { defaultKeyValueDiffers as ɵdefaultKeyValueDiffers, } from './change_detection/change_detection'; export {internalProvideZoneChangeDetection as ɵinternalProvideZoneChangeDetection} from './change_detection/scheduling/ng_zone_scheduling'; +export {ChangeDetectionSchedulerImpl as ɵChangeDetectionSchedulerImpl} from './change_detection/scheduling/zoneless_scheduling_impl'; export { ChangeDetectionScheduler as ɵChangeDetectionScheduler, NotificationSource as ɵNotificationSource, diff --git a/packages/core/testing/src/test_bed_compiler.ts b/packages/core/testing/src/test_bed_compiler.ts index 9ed0dbb37a73c2..fbe64a1a7a67d3 100644 --- a/packages/core/testing/src/test_bed_compiler.ts +++ b/packages/core/testing/src/test_bed_compiler.ts @@ -9,6 +9,8 @@ import {ResourceLoader} from '@angular/compiler'; import { ApplicationInitStatus, + ɵChangeDetectionScheduler as ChangeDetectionScheduler, + ɵChangeDetectionSchedulerImpl as ChangeDetectionSchedulerImpl, Compiler, COMPILER_OPTIONS, Component, @@ -926,7 +928,11 @@ export class TestBedCompiler { private compileTestModule(): void { class RootScopeModule {} compileNgModuleDefs(RootScopeModule as NgModuleType, { - providers: [...this.rootProviderOverrides, internalProvideZoneChangeDetection({})], + providers: [ + ...this.rootProviderOverrides, + internalProvideZoneChangeDetection({}), + {provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl}, + ], }); const providers = [ diff --git a/packages/platform-browser/testing/src/browser.ts b/packages/platform-browser/testing/src/browser.ts index e5a760b6a150a4..cd74f0d80dc80a 100644 --- a/packages/platform-browser/testing/src/browser.ts +++ b/packages/platform-browser/testing/src/browser.ts @@ -15,6 +15,8 @@ import { platformCore, StaticProvider, ɵinternalProvideZoneChangeDetection as internalProvideZoneChangeDetection, + ɵChangeDetectionScheduler as ChangeDetectionScheduler, + ɵChangeDetectionSchedulerImpl as ChangeDetectionSchedulerImpl, } from '@angular/core'; import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser'; @@ -47,6 +49,7 @@ export const platformBrowserTesting = createPlatformFactory( providers: [ {provide: APP_ID, useValue: 'a'}, internalProvideZoneChangeDetection({}), + {provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl}, {provide: PlatformLocation, useClass: MockPlatformLocation}, ], })