Skip to content

Commit 82e9c67

Browse files
authored
feat(core): initRootView event (#10442)
launchEvent is not triggered at the same moment on iOS and Android. iOS is firing after setting the rootView while Android is firing before. Consequently if you need an event for when the rootView is set (to read/write root css variables) you need this event. [skip ci]
1 parent 2237c9b commit 82e9c67

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/core/application/application-common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { Frame } from '../ui/frame';
1212
import type { NavigationEntry } from '../ui/frame/frame-interfaces';
1313
import type { StyleScope } from '../ui/styling/style-scope';
1414
import type { AndroidApplication as IAndroidApplication, iOSApplication as IiOSApplication } from './';
15-
import type { ApplicationEventData, CssChangedEventData, DiscardedErrorEventData, FontScaleChangedEventData, LaunchEventData, LoadAppCSSEventData, NativeScriptError, OrientationChangedEventData, SystemAppearanceChangedEventData, UnhandledErrorEventData } from './application-interfaces';
15+
import type { ApplicationEventData, CssChangedEventData, DiscardedErrorEventData, FontScaleChangedEventData, InitRootViewEventData, LaunchEventData, LoadAppCSSEventData, NativeScriptError, OrientationChangedEventData, SystemAppearanceChangedEventData, UnhandledErrorEventData } from './application-interfaces';
1616

1717
// prettier-ignore
1818
const ORIENTATION_CSS_CLASSES = [
@@ -125,6 +125,7 @@ export class ApplicationCommon {
125125
readonly livesyncEvent = 'livesync';
126126
readonly loadAppCssEvent = 'loadAppCss';
127127
readonly cssChangedEvent = 'cssChanged';
128+
readonly initRootViewEvent = 'initRootView';
128129

129130
// Expose statically for backwards compat on AndroidApplication.on etc.
130131
/**
@@ -368,6 +369,7 @@ export class ApplicationCommon {
368369
this.setRootViewCSSClasses(rootView);
369370
initAccessibilityCssHelper();
370371
initAccessibilityFontScale();
372+
this.notify(<InitRootViewEventData>{ eventName: this.initRootViewEvent, rootView });
371373
}
372374

373375
/**

packages/core/application/application-interfaces.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ export interface CssChangedEventData extends ApplicationEventData {
117117
cssText?: string;
118118
}
119119

120+
/**
121+
* Event data containing information about application css change.
122+
*/
123+
export interface InitRootViewEventData extends ApplicationEventData {
124+
rootView: View;
125+
}
126+
120127
/**
121128
* Data for the Android activity events.
122129
*/

0 commit comments

Comments
 (0)