-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
this.get('store').unloadAll(type) works only once #5447
Comments
|
We´ve got something like a wishlist. All promises are resolved, each step is an userinteraction and not directly chained. |
I am also experiencing this problem, I need to unload models when a user changes the "project" context of our app and it seems to work only once and even some models do not unload at all. |
I'm having this issue too.
|
I've run in to similar issue. Based on first post I've created twiddle: Model returns one post model, but it's called after unloadAll, so it should be empty. Interesting thing is if you comment out line 9 then it works as expected. |
I might be able to shed a little light on this. I don't know how to fix it, but I think I know why it's happening... I had the same problem on one of my apps. I copied the twiddle into a repo to debug easier (thanks @CezaryH). Ember data has an What I found was that on the second call of in this case Sorry I can't be more helpful, I don't know enough about the internals of ED to figure out why the properties get out of sync, or even where/how they're set up. If it's of help to anyone my workaround was to call I would be willing to investigate further if anyone more familiar with ED is able to give me some hints/tips/suggestions. |
I'm also seeing this in 3.6.0 thanks for the workaround @geekygrappler |
I'm encountering this as well on 3.5.0. |
We experience the same problems 🤔 @runspired let me know if you need more information or if the information provided by the others are enough. We worked around this issue the following way: const all = this.store.peekAll(this.modelName);
all.forEach((modelInstance) => modelInstance.unloadRecord()); Nevertheless it's never nice to use a workaround 😉 |
I looked into this and the issue is basically that you need to force the import { run } from '@ember/runloop';
// ...
run(() => store.unloadAll('post')); That said we're working on making some improvements to these APIs that should result in destroy completing synchronously and unload always fully unloading. We're able to do this now because references to these records that we need to keep for relationships can be referenced by identifier instead of by InternalModel or RecordData instance. |
Completed with the removal of InternalModel |
DEBUG: -------------------------------
index.js:158 DEBUG: Ember : 2.16.4
index.js:158 DEBUG: Ember Data : 2.16.4
index.js:158 DEBUG: jQuery : 2.2.4
index.js:158 DEBUG: Ember Simple Auth : 1.6.0
index.js:158 DEBUG: -------------------------------
When i use this.get('store').unloadAll(type) an refetch the same models with the same ids with the RESTAdapter again, this.get('store').unloadAll(type) fails removing them from the store.
Only model entries with an different id will be removed.
this.get('store').findRecord('product', 1) --> Product with id 1 is in the store.
this.get('store').unloadAll('product') --> No Product in the store
this.get('store').findRecord('product', 1) --> Product with id 1 is in the store.
this.get('store').findRecord('product', 2) --> Product with id 1 and 2 is in the store.
this.get('store').unloadAll('product') --> Product with id 1 is in the store.
The text was updated successfully, but these errors were encountered: