fix(in-app-browser): adds missing customscheme type (#3276)

it also adds an overload to the `on` function to pass a generic string to support custom events.
This commit is contained in:
Tim Brust 2020-01-03 18:40:11 +00:00 committed by Daniel Sogl
parent e55a1e1117
commit 240feba76b

View File

@ -123,11 +123,11 @@ export interface InAppBrowserOptions {
[key: string]: any;
}
export type InAppBrowserEventType = 'loadstart' | 'loadstop' | 'loaderror' | 'exit' | 'beforeload' | 'message';
export type InAppBrowserEventType = 'loadstart' | 'loadstop' | 'loaderror' | 'exit' | 'beforeload' | 'message' | 'customscheme';
export interface InAppBrowserEvent extends Event {
/** the event name */
type: InAppBrowserEventType;
type: string;
/** the URL that was loaded. */
url: string;
/** the error code, only in the case of loaderror. */
@ -248,6 +248,28 @@ export class InAppBrowserObject {
}
);
}
/**
* A method that allows you to listen to events happening in the browser.
* @param event {string} Name of the event
* @returns {Observable<InAppBrowserEvent>} Returns back an observable that will listen to the event on subscribe, and will stop listening to the event on unsubscribe.
*/
@InstanceCheck()
on(event: string): Observable<InAppBrowserEvent> {
return new Observable<InAppBrowserEvent>(
(observer: Observer<InAppBrowserEvent>) => {
this._objectInstance.addEventListener(
event,
observer.next.bind(observer)
);
return () =>
this._objectInstance.removeEventListener(
event,
observer.next.bind(observer)
);
}
);
}
}
/**