mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] store: connect function takes hash function in param
With this commit, we can now decides precisely if a component should be rerendered, by using a hash function. By default, the hash function will deep observe each store element coming from the result of the mapStateToProps. closes #24
This commit is contained in:
@@ -113,6 +113,19 @@ export function findInTree<T extends Tree<T>>(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function shallowEqual(objA, objB) {
|
||||
if (objA === objB) {
|
||||
return true;
|
||||
}
|
||||
const keysA = Object.keys(objA);
|
||||
for (let key of keysA) {
|
||||
if (!(key in objB) || objA[key] !== objB[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function patch(C: any, patchName: string, patch: any) {
|
||||
const proto = C.prototype;
|
||||
if (!proto.__patches) {
|
||||
|
||||
Reference in New Issue
Block a user