fix(angular): backButton event uses ionBackButton

This commit is contained in:
Manu Mtz.-Almeida
2018-10-02 13:14:37 +02:00
parent 657c2edc4d
commit 0337c7f567
3 changed files with 13 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import { EventEmitter, Injectable } from '@angular/core';
import { Platforms, getPlatforms, isPlatform } from '@ionic/core';
import { BackButtonDetail, Platforms, getPlatforms, isPlatform } from '@ionic/core';
import { proxyEvent } from '../util/util';
@ -11,7 +11,7 @@ export class Platform {
/**
* @hidden
*/
backButton = new EventEmitter<Event>();
backButton = new EventEmitter<BackButtonDetail>();
/**
* The pause event emits when the native platform puts the application
@ -19,26 +19,26 @@ export class Platform {
* application. This event would emit when a Cordova app is put into
* the background, however, it would not fire on a standard web browser.
*/
pause = new EventEmitter<Event>();
pause = new EventEmitter<void>();
/**
* The resume 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.
*/
resume = new EventEmitter<Event>();
resume = new EventEmitter<void>();
/**
* The resize event emits when the browser window has changed dimensions. This
* could be from a browser window being physically resized, or from a device
* changing orientation.
*/
resize = new EventEmitter<Event>();
resize = new EventEmitter<void>();
constructor() {
proxyEvent(this.pause, document, 'pause');
proxyEvent(this.resume, document, 'resume');
proxyEvent(this.backButton, document, 'backbutton');
proxyEvent(this.backButton, document, 'ionBackButton');
proxyEvent(this.resize, window, 'resize');
let readyResolve: (value: string) => void;

View File

@ -1,4 +1,4 @@
import { ElementRef } from '@angular/core';
import { ElementRef, EventEmitter } from '@angular/core';
export function inputs(instance: any, el: ElementRef, props: string[]) {
props.forEach(propName => {
@ -8,9 +8,9 @@ export function inputs(instance: any, el: ElementRef, props: string[]) {
});
}
export function proxyEvent(emitter: any, el: EventTarget, eventName: string) {
export function proxyEvent<T>(emitter: EventEmitter<T>, el: EventTarget, eventName: string) {
el.addEventListener(eventName, (ev) => {
emitter.emit(ev);
emitter.emit((ev as any).detail as T);
});
}