[IMP] component/qweb: remove t-mounted directive

The t-mounted directive main goals can be achieved with hooks, in a
better and more intuitive way.

closes #308
This commit is contained in:
Géry Debongnie
2019-10-03 10:48:26 +02:00
parent 367725d194
commit 022b29b6a0
7 changed files with 5 additions and 161 deletions
+1 -11
View File
@@ -29,17 +29,6 @@ export function useState<T>(state: T): T {
return __owl__.observer.observe(state);
}
/**
* Mounted hook. The callback will be called when the current component is
* mounted. Note that the component mounted method is called first.
*/
let nextID = 1;
export function onMounted(cb) {
const component: Component<any, any> = Component._current;
component.__owl__.mountedHandlers[`h${nextID++}`] = cb;
}
function makeLifecycleHook(method: string, reverse: boolean = false) {
return function(cb) {
const component: Component<any, any> = Component._current;
@@ -66,6 +55,7 @@ function makeLifecycleHook(method: string, reverse: boolean = false) {
* willUnmount hook. The callback will be called when the current component is
* willUnmounted. Note that the component mounted method is called last.
*/
export const onMounted = makeLifecycleHook("mountedCB", true);
export const onWillUnmount = makeLifecycleHook("willUnmountCB");
export const onWillPatch = makeLifecycleHook("willPatchCB");
export const onPatched = makeLifecycleHook("patchedCB", true);