Skip to content

Commit eac5988

Browse files
committed
Implement a Proxy set trap for Neo.state.Provider data to enable direct reactive assignments #6981
1 parent f1176c0 commit eac5988

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/state/createHierarchicalDataProxy.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ function createNestedProxy(rootProvider, path) {
5757

5858
// 3. If it's neither a data property nor a path to one, it doesn't exist in the state.
5959
return null
60+
},
61+
62+
set(currentTarget, property, value) {
63+
const fullPath = path ? `${path}.${property}` : property;
64+
const ownerDetails = rootProvider.getOwnerOfDataProperty(fullPath);
65+
66+
let targetProvider;
67+
if (ownerDetails) {
68+
targetProvider = ownerDetails.owner;
69+
} else {
70+
// If no owner is found, set it on the rootProvider (the one that created this proxy)
71+
targetProvider = rootProvider;
72+
}
73+
74+
targetProvider.setData(fullPath, value);
75+
return true; // Indicate that the assignment was successful
6076
}
6177
})
6278
}

0 commit comments

Comments
 (0)