mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
up
This commit is contained in:
+13
-3
@@ -99,15 +99,25 @@ export function useEffect<T extends unknown[]>(
|
|||||||
popExecutionContext();
|
popExecutionContext();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const computeDependenciesWithContext = () => {
|
||||||
|
pushExecutionContext(context);
|
||||||
|
let r: any;
|
||||||
|
try {
|
||||||
|
r = computeDependencies();
|
||||||
|
} finally {
|
||||||
|
popExecutionContext();
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
dependencies = computeDependencies();
|
dependencies = computeDependenciesWithContext();
|
||||||
runEffect();
|
runEffect();
|
||||||
});
|
});
|
||||||
|
|
||||||
onPatched(() => {
|
onPatched(() => {
|
||||||
const newDeps = computeDependencies();
|
const newDeps = computeDependenciesWithContext();
|
||||||
const shouldReapply = newDeps.some((val, i) => val !== dependencies[i]);
|
const shouldReapply = newDeps.some((val: any, i: number) => val !== dependencies[i]);
|
||||||
if (shouldReapply) {
|
if (shouldReapply) {
|
||||||
dependencies = newDeps;
|
dependencies = newDeps;
|
||||||
if (cleanup) {
|
if (cleanup) {
|
||||||
|
|||||||
Reference in New Issue
Block a user