fix-next: avoid circular reference (#6812)

This commit is contained in:
Vasil Chimev
2019-01-22 14:37:29 +02:00
committed by GitHub
parent 19dfd163e0
commit 8cb726aedf
3 changed files with 9 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
require("globals"); require("globals");
import { Observable, EventData } from "../data/observable"; import { Observable, EventData } from "../data/observable";
import { View } from "../ui/core/view";
import { import {
trace as profilingTrace, trace as profilingTrace,
time, time,
@@ -35,7 +36,6 @@ export { Observable };
import { import {
AndroidApplication, AndroidApplication,
CssChangedEventData, CssChangedEventData,
getRootView,
iOSApplication, iOSApplication,
LoadAppCSSEventData, LoadAppCSSEventData,
UnhandledErrorEventData, UnhandledErrorEventData,
@@ -79,10 +79,10 @@ export function setApplication(instance: iOSApplication | AndroidApplication): v
app = instance; app = instance;
} }
export function livesync(context?: HmrContext) { export function livesync(rootView: View, context?: HmrContext) {
events.notify(<EventData>{ eventName: "livesync", object: app }); events.notify(<EventData>{ eventName: "livesync", object: app });
const liveSyncCore = global.__onLiveSyncCore; const liveSyncCore = global.__onLiveSyncCore;
let reapplyAppCss = false let reapplyAppCss = false;
if (context) { if (context) {
const fullFileName = getCssFileName(); const fullFileName = getCssFileName();
@@ -91,7 +91,6 @@ export function livesync(context?: HmrContext) {
reapplyAppCss = extensions.some(ext => context.module === fileName.concat(ext)); reapplyAppCss = extensions.some(ext => context.module === fileName.concat(ext));
} }
const rootView = getRootView();
if (reapplyAppCss && rootView) { if (reapplyAppCss && rootView) {
rootView._onCssStateChange(); rootView._onCssStateChange();
} else if (liveSyncCore) { } else if (liveSyncCore) {

View File

@@ -217,7 +217,8 @@ global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
return; return;
} }
livesync(context); const rootView = getRootView();
livesync(rootView, context);
}; };
function initLifecycleCallbacks() { function initLifecycleCallbacks() {

View File

@@ -21,7 +21,7 @@ import { Frame, NavigationEntry } from "../ui/frame";
import * as utils from "../utils/utils"; import * as utils from "../utils/utils";
import { profile, level as profilingLevel, Level } from "../profiling"; import { profile, level as profilingLevel, Level } from "../profiling";
// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430 // NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430
// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved: // TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved:
// https://github.com/NativeScript/ios-runtime/issues/1012 // https://github.com/NativeScript/ios-runtime/issues/1012
var Responder = (<any>UIResponder).extend({ var Responder = (<any>UIResponder).extend({
@@ -161,7 +161,7 @@ class IOSApplication implements IOSApplicationDefinition {
this.setWindowContent(args.root); this.setWindowContent(args.root);
} else { } else {
this._window = UIApplication.sharedApplication.delegate.window; this._window = UIApplication.sharedApplication.delegate.window;
} }
} }
@profile @profile
@@ -378,5 +378,6 @@ global.__onLiveSync = function __onLiveSync(context?: HmrContext) {
return; return;
} }
livesync(context); const rootView = getRootView();
livesync(rootView, context);
} }