Open caracal7 opened 5 years ago
Setting the property values to undefined
will have pretty much the same behavior as leaving them alone, because the reactive functions are only invoked if all inputs are defined.
Maybe try a first implementation that just deletes the property from state, functions and edges? Then we can see how it behaves and think more deeply about the other cases.
I've tested several ways and in my cases better is unset all dependent function states.
const deleteProperty = property => {
const unsetDependents = property => {
if(edges[property])
edges[property].forEach(property2 => {
state[property2] = undefined;
unsetDependents(property2);
});
}
unsetDependents(property)
Object.keys(edges).forEach(edge => {
let index = edges[edge].indexOf(property);
if (!!~index) edges[edge].splice(index, 1);
})
delete state[property];
delete functions[property];
}
I thinking about implementing properties deleting.
For example I have reactive graph like this:
If I delete d property it is not a problem: I need only delete it from states, functions and edges. But if I want to delete c property I can't decide what I need to do with:
P.S. Sorry for my English :)