From a9323c3fcd12153f0ed244b8872b05a32f7396d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Fri, 24 Mar 2023 10:22:53 +0100 Subject: [PATCH] [REF] hooks: avoid confusion for sync hooks `onWillPatch`, `onWillUnmount`, `onWillDestroy` are synchronous hooks. Owl will not wait any promise return by the callback. Yet, the callback return type includes `Promise`, which is confusing as one might think it means the hooks is async. --- src/runtime/lifecycle_hooks.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/lifecycle_hooks.ts b/src/runtime/lifecycle_hooks.ts index e732049d..4074d3fd 100644 --- a/src/runtime/lifecycle_hooks.ts +++ b/src/runtime/lifecycle_hooks.ts @@ -63,7 +63,7 @@ export function onMounted(fn: () => void | any) { node.mounted.push(decorate(fn.bind(node.component), "onMounted")); } -export function onWillPatch(fn: () => Promise | any | void) { +export function onWillPatch(fn: () => any | void) { const node = getCurrent(); const decorate = node.app.dev ? wrapError : (fn: any) => fn; node.willPatch.unshift(decorate(fn.bind(node.component), "onWillPatch")); @@ -75,13 +75,13 @@ export function onPatched(fn: () => void | any) { node.patched.push(decorate(fn.bind(node.component), "onPatched")); } -export function onWillUnmount(fn: () => Promise | void | any) { +export function onWillUnmount(fn: () => void | any) { const node = getCurrent(); const decorate = node.app.dev ? wrapError : (fn: any) => fn; node.willUnmount.unshift(decorate(fn.bind(node.component), "onWillUnmount")); } -export function onWillDestroy(fn: () => Promise | void | any) { +export function onWillDestroy(fn: () => void | any) { const node = getCurrent(); const decorate = node.app.dev ? wrapError : (fn: any) => fn; node.willDestroy.push(decorate(fn.bind(node.component), "onWillDestroy"));