Currently i having a route which is use to findAll the record from a model. But the result comeback as an array so in the template I used {{#each}} to loop them. Originally it comeback two records in the array which is the correct behavior. But whenever i try to transition to another route and transition back it will comeback 4 records which is duplicate. It will multiple each time when i try to transition back. I’m not sure which part is missing or having mistake that cause that behavior. Or variable must be destroy when leave the route?
It sounds like you’re using an ember-concurrency task on a Route, in the model() hook?
You can do that, but it’s not going to do what you think. For example, your template will never show loadModelTask.isRunning as true, because the model hook waits to resolve the returned promise before it will render your template at all. To rule out any confusion around this, first try simplifying your model() hook to something like:
Then if you’re still seeing these duplicate records, your problem is likely to be in the way your ember-data model or adapter are working. For example, if they don’t provide stable IDs, each time you fetch from the server you will end up with “new” copies of the data.
Thanks for the suggestion. But I did simplifying my model by following your suggestion but still getting the duplicate records.
Then most likely is the problem you mentioned was the adapter/ember data model are working. But i’m not quite understand about the “don’t provide stable IDs will getting “new” records”, what does it means? And how it triggered the adapter to work?
I mean that if ember-data is showing you four entries, those four entries must all have different IDs from each other. So maybe the IDs are not staying stable. If you can share more about how your model & adapter works we could maybe help further.