forked from angular/zone.js
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcordova.ts
21 lines (21 loc) · 819 Bytes
/
cordova.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
if (global.cordova) {
const nativeExec: Function = api.patchMethod(
global.cordova, 'exec', (delegate: Function) => function(self: any, args: any[]) {
if (args.length > 0 && typeof args[0] === 'function') {
args[0] = Zone.current.wrap(args[0], 'cordova.exec.success');
}
if (args.length > 1 && typeof args[1] === 'function') {
args[1] = Zone.current.wrap(args[1], 'cordova.exec.error');
}
return nativeExec.apply(self, args);
});
}
});