mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] types: improve type of useExternalListener
so it can work on window closes #613
This commit is contained in:
+6
-1
@@ -149,7 +149,12 @@ export function useSubEnv(nextEnv) {
|
|||||||
* in the constructor of the OWL component that needs to be notified,
|
* in the constructor of the OWL component that needs to be notified,
|
||||||
* `useExternalListener(window, 'click', this._doSomething);`
|
* `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);
|
const boundHandler = handler.bind(Component.current);
|
||||||
|
|
||||||
onMounted(() => target.addEventListener(eventName, boundHandler, eventParams));
|
onMounted(() => target.addEventListener(eventName, boundHandler, eventParams));
|
||||||
|
|||||||
Reference in New Issue
Block a user