Data best practices #9036
Replies: 2 comments
-
What you are doing is pretty common. I have POST and data UPDATE happening in app dialogs. If it fails for some reason I can inform the user before closing the dialog. That is a decent practice. When the save is successful I will emit an update event. Parent listens for the update events and fetches new data if needed. If the data is core to the app I will use a store pattern and save the data in Pinia. What goes into a store is subjective. The general rule I follow is critical app data goes into the store and extraneous UI data I will pass around with props/emits or callbacks. |
Beta Was this translation helpful? Give feedback.
-
Use Pinia. |
Beta Was this translation helpful? Give feedback.
-
I have a parent component that gets data from a database and stores it in an array.
I then loop over the array and display the data in a table. Basically a table of parts.
The user can click on a part and edit that part. It opens in a modal dialog.
So the user is editing one record from the multidimensional array from the parent.
The data is sent to the modal component via a prop.
So my question is, when the user updates the data, how do I get that new data back to the parent and into that array stored there?
I know I can emit that data back....but the parent has to read it back into the database for the correct record.
Right now, I am just updating the database from the modal and calling a page reload when the dialog closes. I know this is not the best solution.
Any ideas of how to best handle this? Should I be using/storing the data differently?
Any help is greatly appreciated.
Regards,
Mike
Beta Was this translation helpful? Give feedback.
All reactions