mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] component: add name property on nodes for debug purposes
also, improves the implementation of subscriptions
This commit is contained in:
committed by
Samuel Degueldre
parent
0625b5883a
commit
47c6d6cc3c
@@ -117,7 +117,3 @@ Dev mode activates some additional checks and developer amenities:
|
|||||||
- [Props validation](./props.md#props-validation) is performed
|
- [Props validation](./props.md#props-validation) is performed
|
||||||
- [t-foreach](./templates.md#loops) loops check for key unicity
|
- [t-foreach](./templates.md#loops) loops check for key unicity
|
||||||
- Lifecycle hooks are wrapped to report their errors in a more developer-friendly way
|
- Lifecycle hooks are wrapped to report their errors in a more developer-friendly way
|
||||||
- Component nodes (the `__owl__` property on components) have an additional "subscriptions"
|
|
||||||
property, containing a list of objects that the component is observing through the reactivity
|
|
||||||
system, as well as which keys are observed for each object, which can be useful for
|
|
||||||
debugging extraneous or missing renders
|
|
||||||
|
|||||||
@@ -58,13 +58,6 @@ export function useState<T extends object>(state: T): Reactive<T> | NonReactive<
|
|||||||
batchedRenderFunctions.set(node, render);
|
batchedRenderFunctions.set(node, render);
|
||||||
// manual implementation of onWillDestroy to break cyclic dependency
|
// manual implementation of onWillDestroy to break cyclic dependency
|
||||||
node.willDestroy.push(clearReactivesForCallback.bind(null, render));
|
node.willDestroy.push(clearReactivesForCallback.bind(null, render));
|
||||||
if (node.app.dev) {
|
|
||||||
Object.defineProperty(node, "subscriptions", {
|
|
||||||
get() {
|
|
||||||
return getSubscriptions(render);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return reactive(state, render);
|
return reactive(state, render);
|
||||||
}
|
}
|
||||||
@@ -394,4 +387,16 @@ export class ComponentNode<P extends object = any, E = any> implements VNode<Com
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Some debug helpers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
get name(): string {
|
||||||
|
return this.component.constructor.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
get subscriptions(): ReturnType<typeof getSubscriptions> {
|
||||||
|
const render = batchedRenderFunctions.get(this);
|
||||||
|
return render ? getSubscriptions(render) : [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user