Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8f8691a

Browse files
committed
fix(platform-providers): Remove a circular import.
1 parent 3e478e9 commit 8f8691a

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

‎nativescript-angular/platform-common.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if ((<any>global).___TS_UNUSED) {
2626
}
2727

2828
import { rendererLog, rendererError } from "./trace";
29-
import { PAGE_FACTORY, PageFactory, defaultPageFactoryProvider } from "./platform-providers";
29+
import { PAGE_FACTORY, PageFactory, defaultPageFactoryProvider,setRootPage } from "./platform-providers";
3030

3131
import { start, setCssFileName } from "tns-core-modules/application";
3232
import { topmost, NavigationEntry } from "tns-core-modules/ui/frame";
@@ -61,20 +61,11 @@ export const COMMON_PROVIDERS = [
6161

6262
export class NativeScriptPlatformRef extends PlatformRef {
6363
private _bootstrapper: BootstrapperAction;
64-
private static _rootPageRef: WeakRef<Page>;
6564

6665
constructor(private platform: PlatformRef, private appOptions?: AppOptions) {
6766
super();
6867
}
6968

70-
static set rootPage(page: Page) {
71-
NativeScriptPlatformRef._rootPageRef = new WeakRef(page);
72-
}
73-
74-
static get rootPage(): Page {
75-
return NativeScriptPlatformRef._rootPageRef.get();
76-
}
77-
7869
bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>> {
7970
this._bootstrapper = () => this.platform.bootstrapModuleFactory(moduleFactory);
8071

@@ -158,7 +149,7 @@ export class NativeScriptPlatformRef extends PlatformRef {
158149
const navEntry: NavigationEntry = {
159150
create: (): Page => {
160151
let page = pageFactory({ isBootstrap: true, isLivesync });
161-
NativeScriptPlatformRef.rootPage=page;
152+
setRootPage(page);
162153
if (this.appOptions) {
163154
page.actionBarHidden = this.appOptions.startPageActionBarHidden;
164155
}

‎nativescript-angular/platform-providers.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@ if ((<any>global).___TS_UNUSED) {
1515
})();
1616
}
1717

18+
let _rootPageRef: WeakRef<Page>;
19+
20+
export function setRootPage(page: Page): void {
21+
_rootPageRef = new WeakRef(page);
22+
}
23+
24+
export function getRootPage(): Page {
25+
return _rootPageRef && _rootPageRef.get();
26+
}
27+
1828
// Use an exported function to make the AoT compiler happy.
1929
export function getDefaultPage(): Page {
2030
const frame = topmost();
21-
if (frame) {
22-
return frame.currentPage;
23-
} else {
24-
return null;
25-
}
31+
return getRootPage() || (frame && frame.currentPage);
2632
}
2733

2834
export const defaultPageProvider = { provide: Page, useFactory: getDefaultPage };

‎nativescript-angular/renderer.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { NgView } from "./element-registry";
1414
import { rendererLog as traceLog } from "./trace";
1515
import { escapeRegexSymbols } from "tns-core-modules/utils/utils";
1616
import { Device } from "tns-core-modules/platform";
17-
import { NativeScriptPlatformRef } from "./platform-common";
17+
import { getRootPage } from "./platform-providers";
1818

1919
import { NativeScriptAnimationDriver } from "./animation-driver";
2020

@@ -47,7 +47,7 @@ export class NativeScriptRootRenderer implements RootRenderer {
4747

4848
public get rootView(): View {
4949
if (!this._rootView) {
50-
this._rootView = NativeScriptPlatformRef.rootPage || topmost().currentPage;
50+
this._rootView = getRootPage() || topmost().currentPage;
5151
}
5252
return this._rootView;
5353
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /