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();
|
||||
}
|
||||
};
|
||||
const computeDependenciesWithContext = () => {
|
||||
pushExecutionContext(context);
|
||||
let r: any;
|
||||
try {
|
||||
r = computeDependencies();
|
||||
} finally {
|
||||
popExecutionContext();
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
dependencies = computeDependencies();
|
||||
dependencies = computeDependenciesWithContext();
|
||||
runEffect();
|
||||
});
|
||||
|
||||
onPatched(() => {
|
||||
const newDeps = computeDependencies();
|
||||
const shouldReapply = newDeps.some((val, i) => val !== dependencies[i]);
|
||||
const newDeps = computeDependenciesWithContext();
|
||||
const shouldReapply = newDeps.some((val: any, i: number) => val !== dependencies[i]);
|
||||
if (shouldReapply) {
|
||||
dependencies = newDeps;
|
||||
if (cleanup) {
|
||||
|
||||
Reference in New Issue
Block a user