Skip to content

Commit e0dab64

Browse files
committed
feat: make it easier to configure custom flags
1 parent 96d4c0e commit e0dab64

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { DOCUMENT, LocationChangeListener, LocationStrategy, PlatformLocation }
1919
import { NativeScriptPlatformRefProxy } from './platform-ref';
2020
import { AppHostView } from './app-host-view';
2121
import { Color, GridLayout } from '@nativescript/core';
22-
import { defaultPageFactory, PAGE_FACTORY } from './tokens';
22+
import { defaultPageFactory, ENABLE_REUSABE_VIEWS, PAGE_FACTORY, WRAP_CD_IN_TRANSACTION } from './tokens';
2323
import { AppLaunchView } from './application';
2424
import { NATIVESCRIPT_MODULE_PROVIDERS, NATIVESCRIPT_MODULE_STATIC_PROVIDERS } from './nativescript';
2525

@@ -143,12 +143,27 @@ export interface BootstrapContext {
143143
platformRef?: PlatformRef;
144144
}
145145

146-
function createProvidersConfig(options?: ApplicationConfig, context?: BootstrapContext) {
146+
export interface NativeScriptApplicationConfig extends ApplicationConfig {
147+
reusableViews?: boolean;
148+
ios?: {
149+
wrapChangeDetectionInTransaction?: boolean;
150+
};
151+
}
152+
153+
function createProvidersConfig(options?: NativeScriptApplicationConfig, context?: BootstrapContext) {
154+
const nsProviders: StaticProvider[] = [];
155+
if (options?.reusableViews) {
156+
nsProviders.push({ provide: ENABLE_REUSABE_VIEWS, useValue: true });
157+
}
158+
if (options?.ios?.wrapChangeDetectionInTransaction) {
159+
nsProviders.push({ provide: WRAP_CD_IN_TRANSACTION, useValue: true });
160+
}
147161
return {
148162
platformRef: context?.platformRef,
149163
appProviders: [
150164
...NATIVESCRIPT_MODULE_STATIC_PROVIDERS,
151165
...NATIVESCRIPT_MODULE_PROVIDERS,
166+
...nsProviders,
152167
...(options?.providers ?? []),
153168
],
154169
platformProviders: context?.platformRef ? [] : COMMON_PROVIDERS,
@@ -157,7 +172,7 @@ function createProvidersConfig(options?: ApplicationConfig, context?: BootstrapC
157172

158173
export function bootstrapApplication(
159174
rootComponent: Type<any>,
160-
options?: ApplicationConfig,
175+
options?: NativeScriptApplicationConfig,
161176
context?: BootstrapContext,
162177
) {
163178
return ɵinternalCreateApplication({
@@ -166,7 +181,7 @@ export function bootstrapApplication(
166181
});
167182
}
168183

169-
export function createApplication(options?: ApplicationConfig, context?: BootstrapContext) {
184+
export function createApplication(options?: NativeScriptApplicationConfig, context?: BootstrapContext) {
170185
return ɵinternalCreateApplication(createProvidersConfig(options, context));
171186
}
172187

packages/angular/src/lib/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {
88
BootstrapContext,
99
COMMON_PROVIDERS,
1010
HmrOptions,
11+
NativeScriptApplicationConfig,
1112
NativeScriptDocument,
1213
NativeScriptSanitizer,
1314
defaultPageFactoryProvider,

0 commit comments

Comments
 (0)