Skip to content

Commit

Permalink
refactor(core): drop unused SCHEDULER provider (#45102) (#45222)
Browse files Browse the repository at this point in the history
The `SCHEDULER` provider was used previously when both ViewEngine and Ivy code was present. After some prior refactoring, all references to the `SCHEDULER` token were removed, but the token itself remains present in the `ApplicationModule`, which makes it non-tree-shakable.

This commit removes the `SCHEDULER` token as unused.

PR Close #45102

PR Close #45222
  • Loading branch information
AndrewKushnir authored and thePunderWoman committed Mar 1, 2022
1 parent 8907fbb commit 2bebaa9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
23 changes: 0 additions & 23 deletions packages/core/src/application_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {DEFAULT_CURRENCY_CODE, LOCALE_ID} from './i18n/tokens';
import {ComponentFactoryResolver} from './linker';
import {Compiler} from './linker/compiler';
import {NgModule} from './metadata';
import {SCHEDULER} from './render3/component_ref';
import {NgZone} from './zone';

declare const $localize: {locale?: string};
Expand Down Expand Up @@ -62,7 +61,6 @@ export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
useClass: ApplicationRef,
deps: [NgZone, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
},
{provide: SCHEDULER, deps: [NgZone], useFactory: zoneSchedulerFactory},
{
provide: ApplicationInitStatus,
useClass: ApplicationInitStatus,
Expand All @@ -78,27 +76,6 @@ export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
{provide: DEFAULT_CURRENCY_CODE, useValue: USD_CURRENCY_CODE},
];

/**
* Schedule work at next available slot.
*
* In Ivy this is just `requestAnimationFrame`. For compatibility reasons when bootstrapped
* using `platformRef.bootstrap` we need to use `NgZone.onStable` as the scheduling mechanism.
* This overrides the scheduling mechanism in Ivy to `NgZone.onStable`.
*
* @param ngZone NgZone to use for scheduling.
*/
export function zoneSchedulerFactory(ngZone: NgZone): (fn: () => void) => void {
let queue: (() => void)[] = [];
ngZone.onStable.subscribe(() => {
while (queue.length) {
queue.pop()!();
}
});
return function(fn: () => void) {
queue.push(fn);
};
}

/**
* Configures the root injector for an app with
* providers of `@angular/core` dependencies that `ApplicationRef` needs
Expand Down
11 changes: 0 additions & 11 deletions packages/core/src/render3/component_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {ChangeDetectorRef as ViewEngine_ChangeDetectorRef} from '../change_detection/change_detector_ref';
import {InjectionToken} from '../di/injection_token';
import {Injector} from '../di/injector';
import {InjectFlags} from '../di/interface/injector';
import {ProviderToken} from '../di/provider_token';
Expand Down Expand Up @@ -36,7 +35,6 @@ import {createElementNode, writeDirectClass} from './node_manipulation';
import {extractAttrsAndClassesFromSelector, stringifyCSSSelectorList} from './node_selector_matcher';
import {enterView, leaveView} from './state';
import {setUpAttributes} from './util/attrs_utils';
import {defaultScheduler} from './util/misc_utils';
import {getTNode} from './util/view_utils';
import {RootViewRef, ViewRef} from './view_ref';

Expand Down Expand Up @@ -71,15 +69,6 @@ function getNamespace(elementName: string): string|null {
return name === 'svg' ? SVG_NAMESPACE : (name === 'math' ? MATH_ML_NAMESPACE : null);
}

/**
* A change detection scheduler token for {@link RootContext}. This token is the default value used
* for the default `RootContext` found in the {@link ROOT_CONTEXT} token.
*/
export const SCHEDULER = new InjectionToken<((fn: () => void) => void)>('SCHEDULER_TOKEN', {
providedIn: 'root',
factory: () => defaultScheduler,
});

function createChainedInjector(rootViewInjector: Injector, moduleInjector: Injector): Injector {
return {
get: <T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T => {
Expand Down

0 comments on commit 2bebaa9

Please sign in to comment.