Skip to content

Commit 00f319c

Browse files
committed
feat: expose createApplication and allow passing in a platformRef
1 parent 7de9f41 commit 00f319c

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

packages/angular/src/lib/platform-nativescript.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,19 @@ export const COMMON_PROVIDERS: StaticProvider[] = [
139139
];
140140

141141
export const platformNativeScript = createPlatformFactory(platformCore, 'nativescriptDynamic', COMMON_PROVIDERS);
142-
function createProvidersConfig(options?: ApplicationConfig) {
142+
export interface BootstrapContext {
143+
platformRef?: PlatformRef;
144+
}
145+
146+
function createProvidersConfig(options?: ApplicationConfig, context?: BootstrapContext) {
143147
return {
148+
platformRef: context?.platformRef,
144149
appProviders: [
145150
...NATIVESCRIPT_MODULE_STATIC_PROVIDERS,
146151
...NATIVESCRIPT_MODULE_PROVIDERS,
147152
...(options?.providers ?? []),
148153
],
149-
platformProviders: COMMON_PROVIDERS,
154+
platformProviders: context?.platformRef ? [] : COMMON_PROVIDERS,
150155
};
151156
}
152157

@@ -157,8 +162,8 @@ export function bootstrapApplication(rootComponent: Type<any>, options?: Applica
157162
});
158163
}
159164

160-
export function createApplication(options?: ApplicationConfig) {
161-
return ɵinternalCreateApplication(createProvidersConfig(options));
165+
export function createApplication(options?: ApplicationConfig, context?: BootstrapContext) {
166+
return ɵinternalCreateApplication(createProvidersConfig(options, context));
162167
}
163168

164169
export interface HmrOptions {

packages/angular/src/lib/public_api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './view-refs';
55
export * from './app-host-view';
66
export {
77
AppOptions,
8+
BootstrapContext,
89
COMMON_PROVIDERS,
910
HmrOptions,
1011
NativeScriptDocument,
@@ -13,6 +14,7 @@ export {
1314
platformNativeScriptDynamic,
1415
platformNativeScript,
1516
bootstrapApplication,
17+
createApplication,
1618
} from './platform-nativescript';
1719
export * from './cdk/detached-loader';
1820
export {

0 commit comments

Comments
 (0)