mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-04 00:13:06 +08:00
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:
parent
e55a1e1117
commit
240feba76b
@ -123,11 +123,11 @@ export interface InAppBrowserOptions {
|
|||||||
[key: string]: any;
|
[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 {
|
export interface InAppBrowserEvent extends Event {
|
||||||
/** the event name */
|
/** the event name */
|
||||||
type: InAppBrowserEventType;
|
type: string;
|
||||||
/** the URL that was loaded. */
|
/** the URL that was loaded. */
|
||||||
url: string;
|
url: string;
|
||||||
/** the error code, only in the case of loaderror. */
|
/** 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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user