Skip to content

Commit

Permalink
fix(in-app-browser): adds missing customscheme type (#3276)
Browse files Browse the repository at this point in the history
it also adds an overload to the `on` function to pass a generic string to support custom events.
  • Loading branch information
timbru31 authored and danielsogl committed Jan 3, 2020
1 parent e55a1e1 commit 240feba
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/@ionic-native/plugins/in-app-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
);
}
);
}
}

/**
Expand Down

0 comments on commit 240feba

Please sign in to comment.