-
Notifications
You must be signed in to change notification settings - Fork 2
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
feature request: return indexes #16
Comments
oh i find solution with https://www.npmjs.com/package/just-diff-apply |
Good thoughts. I've been meaning to add more options in that help real world scenarios. I'll add this feature in the next release. Let me know if you have any other ideas. Thanks! |
@tjmoses thanks for the answer)
|
Hmm, I'll probably just return a tuple and let anyone name them how they want. |
@tjmoses tuple is great idea :) |
so demonstrate example: before if (deletedVals) {
deletedVals.forEach((value) => {
const index = state.findIndex((_) => _.id === value.id)
state.splice(index, 1)
});
}
if (updatedVals) {
updatedVals.forEach((value) => {
const index = state.findIndex((_) => _.id === value.id)
state[index] = value
})
} after if (deletedVals) {
deletedVals.forEach(({ index }) => state.splice(index, 1))
}
if (updatedVals) {
updatedVals.forEach(({ value, index }) => state[index] = value)
} |
Gotcha, def makes sense. Another idea I had was to return functions vs. values so your second
Although, I would use some immutable state library like Immer to mutate the state. |
add functionality for return indexed
e.g. add option to return keys
{ extend: true }
, and we can get the resultthis is necessary so that later it was not necessary to restart the search function by index if you need to work with reactive data
The text was updated successfully, but these errors were encountered: