-
Notifications
You must be signed in to change notification settings - Fork 2.4k
made more of the datasets dynamic #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dataset.data.forEach(function (point, pid) { | ||
currentData[sid].data[pid] = nextData[sid].data[pid]; | ||
}); | ||
|
||
delete dataset.data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey,
Wouldn't this mutate the props ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically... yes.
But since we're building a new version of the dataset on every render for now this is sadly the only way of making sure we don't miss new properties that get passed in without doing a bunch of deepEquals. In the future I would like to make this more immutable, but for now this was the fastest way to get a fix out the door. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I'm not sure we are building the new version of data set on each render.
Regardless, if we can just do:
const { data, ...dataset } = dataset
instead of delete dataset.data;
I would be really happy 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. sorry its early here. :-p Do you mean a complete line replacement of delete to your proposal like this?
nextData.forEach(function (dataset, sid) {
if (currentData[sid] && currentData[sid].data) {
currentData[sid].data.splice(nextData[sid].data.length);
dataset.data.forEach(function (point, pid) {
currentData[sid].data[pid] = nextData[sid].data[pid];
});
const { data, ...dataset } = dataset;
currentData[sid] = {
data: currentData[sid].data,
...currentData[sid],
...dataset
}
} else {
currentData[sid] = nextData[sid];
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh... I didn't even realize you could do that this way. Neat!
cheers mate! |
made it so we can dynamically update more than just the data