Skip to content

Commit c654934

Browse files
author
Vladimir Enchev
committed
application module events added
1 parent 79caa91 commit c654934

File tree

6 files changed

+231
-109
lines changed

6 files changed

+231
-109
lines changed

application/application-common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import definition = require("application");
33
import fs = require("file-system");
44
import fileSystemAccess = require("file-system/file-system-access");
55
import styleScope = require("ui/styling/style-scope");
6+
import observable = require("data/observable");
7+
8+
var events = new observable.Observable();
9+
require("utils/module-merge").merge(events, exports);
610

711
export var cssFile: string = "app.css"
812

application/application.android.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ var initEvents = function () {
4343
if (exports.onExit) {
4444
exports.onExit();
4545
}
46+
47+
exports.notify({ eventName: "onExit", object: androidApp, android: activity, ios: undefined });
48+
4649
androidApp.startActivity = undefined;
4750
}
4851

@@ -58,6 +61,9 @@ var initEvents = function () {
5861
if (exports.onSuspend) {
5962
exports.onSuspend();
6063
}
64+
65+
exports.notify({ eventName: "onSuspend", object: androidApp, android: activity, ios: undefined });
66+
6167
}
6268

6369
if (androidApp.onActivityPaused) {
@@ -69,6 +75,9 @@ var initEvents = function () {
6975
if (exports.onResume) {
7076
exports.onResume();
7177
}
78+
79+
exports.notify({ eventName: "onResume", object: androidApp, android: activity, ios: undefined });
80+
7281
}
7382

7483
if (androidApp.onActivityResumed) {
@@ -183,6 +192,8 @@ class AndroidApplication implements dts.AndroidApplication {
183192
exports.onLaunch(intent);
184193
}
185194

195+
exports.notify({ eventName: "onLaunch", object: this, android: intent, ios: undefined });
196+
186197
/* In the onLaunch event we expect the following setup, which ensures a root frame:
187198
* var frame = require("ui/frame");
188199
* var rootFrame = new frame.Frame();
@@ -224,6 +235,8 @@ global.__onUncaughtError = function (error: Error) {
224235
}
225236

226237
exports.onUncaughtError(nsError);
238+
239+
exports.notify({ eventName: "onUncaughtError", object: appModule.android, android: error, ios: undefined });
227240
}
228241

229242
exports.start = function () {

0 commit comments

Comments
 (0)