mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Observable needs __extends function which comes from globals in the case of Snapshot.
This commit is contained in:
@ -1,16 +1,11 @@
|
|||||||
import { Observable, EventData } from "data/observable";
|
// Require globals first so that snapshot takes __extends function.
|
||||||
|
require("globals");
|
||||||
|
|
||||||
|
import { Observable, EventData } from "data/observable";
|
||||||
|
|
||||||
const events = new Observable();
|
const events = new Observable();
|
||||||
function __export(m) {
|
// First merge all functions from events into application-common so that later appModule.on will be defined.
|
||||||
for (var p in m) { if (!exports.hasOwnProperty(p)) { exports[p] = m[p]; } }
|
global.moduleMerge(events, exports);
|
||||||
}
|
|
||||||
|
|
||||||
__export(events);
|
|
||||||
|
|
||||||
export { Observable };
|
|
||||||
|
|
||||||
// NOTE: This requires modules that requires application.on so the above should be done before globals is required.
|
|
||||||
import "globals";
|
|
||||||
|
|
||||||
import { NativeScriptError, UnhandledErrorEventData, iOSApplication, AndroidApplication, CssChangedEventData } from "application";
|
import { NativeScriptError, UnhandledErrorEventData, iOSApplication, AndroidApplication, CssChangedEventData } from "application";
|
||||||
import { NavigationEntry } from "ui/frame";
|
import { NavigationEntry } from "ui/frame";
|
||||||
|
@ -102,11 +102,6 @@ class Device implements DeviceDefinition {
|
|||||||
class MainScreen implements ScreenMetricsDefinition {
|
class MainScreen implements ScreenMetricsDefinition {
|
||||||
private _metrics: android.util.DisplayMetrics;
|
private _metrics: android.util.DisplayMetrics;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
// NOTE: This will be memory leak but we MainScreen is singleton
|
|
||||||
appModule.on("cssChanged", this.cssChanged, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private cssChanged(args: appModule.CssChangedEventData): void {
|
private cssChanged(args: appModule.CssChangedEventData): void {
|
||||||
if (!this._metrics) {
|
if (!this._metrics) {
|
||||||
this._metrics = new android.util.DisplayMetrics();
|
this._metrics = new android.util.DisplayMetrics();
|
||||||
@ -121,6 +116,9 @@ class MainScreen implements ScreenMetricsDefinition {
|
|||||||
|
|
||||||
private get metrics(): android.util.DisplayMetrics {
|
private get metrics(): android.util.DisplayMetrics {
|
||||||
if (!this._metrics) {
|
if (!this._metrics) {
|
||||||
|
// NOTE: This will be memory leak but we MainScreen is singleton
|
||||||
|
appModule.on("cssChanged", this.cssChanged, this);
|
||||||
|
|
||||||
this._metrics = new android.util.DisplayMetrics();
|
this._metrics = new android.util.DisplayMetrics();
|
||||||
this.initMetrics();
|
this.initMetrics();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user