refactor(all): cosmetic changes + app.resize as event emitter

This commit is contained in:
Manu Mtz.-Almeida
2017-02-16 16:02:55 +01:00
parent f577e54f38
commit be0b6a8872
12 changed files with 103 additions and 119 deletions

View File

@ -38,7 +38,6 @@ export class Platform {
private _ua: string;
private _qp = new QueryParams();
private _nPlt: string;
private _onResizes: Array<Function> = [];
private _readyPromise: Promise<any>;
private _readyResolve: any;
private _bbActions: BackButtonAction[] = [];
@ -404,6 +403,13 @@ export class Platform {
*/
resume: EventEmitter<Event> = new EventEmitter<Event>();
/**
* The resize event emits when the native platform pulls the application
* out from the background. This event would emit when a Cordova app comes
* out from the background, however, it would not fire on a standard web browser.
*/
resize: EventEmitter<Event> = new EventEmitter<Event>();
/**
* The back button event is triggered when the user presses the native
* platform's back button, also referred to as the "hardware" back button.
@ -737,18 +743,6 @@ export class Platform {
}
}
/**
* @private
*/
onResize(cb: Function): Function {
const self = this;
self._onResizes.push(cb);
return function() {
removeArrayItem(self._onResizes, cb);
};
}
/**
* @private
*/
@ -812,14 +806,7 @@ export class Platform {
if (this.hasFocusedTextInput() === false) {
this._isPortrait = null;
}
for (let i = 0; i < this._onResizes.length; i++) {
try {
this._onResizes[i]();
} catch (e) {
console.error(e);
}
}
this.resize.emit();
}, 200);
}, { passive: true, zone: true });
}, 2000);