Skip to content

Commit 21cc42b

Browse files
committed
fix: rename withComponentInputBinding to provideComponentInputBinding for consistency and don't use magic numbers
1 parent 30367a5 commit 21cc42b

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

apps/nativescript-demo-ng/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
provideNativeScriptNgZone,
55
provideNativeScriptRouter,
66
runNativeScriptAngularApp,
7-
withComponentInputBinding,
7+
provideComponentInputBinding,
88
} from '@nativescript/angular';
99
import { Trace, Utils, SplitView } from '@nativescript/core';
1010

@@ -39,7 +39,7 @@ runNativeScriptAngularApp({
3939
providers: [
4040
provideNativeScriptHttpClient(withInterceptorsFromDi()),
4141
provideNativeScriptRouter(routes),
42-
withComponentInputBinding(),
42+
provideComponentInputBinding(),
4343
// provideNativeScriptRouter(SPLIT_VIEW_ROUTES),
4444
ZONELESS ? provideZonelessChangeDetection() : provideNativeScriptNgZone(),
4545
],

packages/angular/src/lib/legacy/router/router.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Router,
1818
ROUTES,
1919
provideRouter,
20+
withComponentInputBinding as angularWithComponentInputBinding,
2021
} from '@angular/router';
2122
import { LocationStrategy, PlatformLocation } from '@angular/common';
2223
import { NSRouterLink } from './ns-router-link';
@@ -42,11 +43,13 @@ export { NSLocationStrategy } from './ns-location-strategy';
4243
export { NSEmptyOutletComponent } from './ns-empty-outlet.component';
4344
export type { ComponentInputBindingOptions } from './router-component-input-binder';
4445

46+
const COMPONENT_INPUT_BINDING_FEATURE_KIND = (angularWithComponentInputBinding() as any).ɵkind;
47+
4548
function inputBinderProviders(options: ComponentInputBindingOptions = {}): Provider[] {
4649
return [{ provide: INPUT_BINDER, useFactory: () => new RoutedComponentInputBinder(options) }];
4750
}
4851

49-
export function withComponentInputBinding(options: ComponentInputBindingOptions = {}): Provider[] {
52+
export function provideComponentInputBinding(options: ComponentInputBindingOptions = {}): Provider[] {
5053
return inputBinderProviders(options);
5154
}
5255

@@ -98,7 +101,7 @@ export function rootRoute(router: Router): ActivatedRoute {
98101
}
99102

100103
export function provideNativeScriptRouter(routes: Routes, ...features: RouterFeatures[]) {
101-
const hasInputBinding = features.some((f: any) => f.ɵkind === 8 /* RouterFeatureKind.ComponentInputBindingFeature */);
104+
const hasInputBinding = features.some((f: any) => f.ɵkind === COMPONENT_INPUT_BINDING_FEATURE_KIND);
102105
return makeEnvironmentProviders([
103106
provideRouter(routes, ...features),
104107
{

0 commit comments

Comments
 (0)