[FIX] types: improve type of useExternalListener

so it can work on window

closes #613
This commit is contained in:
Géry Debongnie
2020-01-18 09:42:43 +01:00
committed by aab-odoo
parent 3845607feb
commit c62c3fea19
+6 -1
View File
@@ -149,7 +149,12 @@ export function useSubEnv(nextEnv) {
* in the constructor of the OWL component that needs to be notified,
* `useExternalListener(window, 'click', this._doSomething);`
* */
export function useExternalListener(target: HTMLElement, eventName: string, handler, eventParams?) {
export function useExternalListener(
target: HTMLElement | typeof window,
eventName: string,
handler,
eventParams?
) {
const boundHandler = handler.bind(Component.current);
onMounted(() => target.addEventListener(eventName, boundHandler, eventParams));