Closed jackcallister closed 9 years ago
Deleting is always tricky because there is no first class notion of a schema. We don't know which parts of state are actually references to IDs and need to be updated.
I see three solutions:
isDeleted
on the model. This way it's still there, but it's up to the UI to filter deleted items out.Thanks for the advice. I think the isDeleted
field is a pragmatic solution suitable for my scenario. I'm not very familiar with normalizr but the concept looks appealing, especially for a larger more relationship heavy data set. I'll have to take a closer look.
This is more database related than just Redux but here goes...
Let's say Redux has a store that looks like this:
My interface has the ability to delete a meal, here's the relevant reducer function:
There is a bug here. I must also remove the id from the selectedMeal array too.
The interesting thing is my interface doesn't bork but I know the store is not 'truthful'. I must manually remove the id reference from the store. That makes sense but I am wondering if there is a better way?
Taking a look at this Baobab article provides some interesting thoughts.