Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

createRecord on model leaves behind shell of a record when not saved. What are some solutions?

$
0
0

@sheriffderek wrote:

Let’s say I have a concept for ‘user’ or an ‘order’ that uses a form. I can create a record on the store and return it in the model of a route. Then in the form, the data knows how to act based on that model schema. This is great (specifically - I’m using a mirage setup to experiment with some things).

When I visit the ‘orders/create’ route - or wherever the record is being created - it does just that - It creates the record / but then if I leave… the record is just kinda there for no reason. Is this a problem? How do people normally deal with this? If you aren’t listing the records, you might not even notice but if you look at the ember-inspector - you’ll see the records / or if you list them out in another route - you’d see a bunch of data-less list-items.

First thoughts would be to check when leaving the route - and delete the record / but that doesn’t seem very smooth. Then I could hold off on creating the record until I had all of the data / but then I couldn’t take advantage of computed properties. Or someone suggested I could just let them exist - and filter them out of lists by checking for something like the existence of an ID.

What do you think?

https://ember-twiddle.com/839c2597d32cfad801c87c358497ddd0?openFiles=routes.orders.js%2C

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles