-
-
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
unregistering then re-registering a model doesn't clear the factoryCache #5000
Comments
Ember Data is doing its own caching around There are a few different possibilities here that I can think of:
I personally am in the camp of both 2 and 3 😸, but there are likely good reasons for the extra layer of caching (e.g. to support |
@runspired may have more insight round item 2 above (e.g. if we do need the secondary caching level)... |
I don't believe we should allow cache-busting in ember-data for TL;DR In the case described in the original Ember issue above, the following refactor would be better. before
after
|
Basically the reason I don't think we should cache-bust
The caching of attributes and relationships means that even using |
cc @rwjblue, unless you disagree I think we can close this since unregistering and then re-registering is an upstream concern (and has been cleaned up there). |
I tend to agree. |
Closing as wont-fix. Many thanks to @Leooo for reporting and for taking the time to write a test for us to discuss this with. |
Thanks for showing the proper fix @runspired. That helps |
Note to anyone it may help: runspired code above works, with one typo:
=>
(Ember 2.15) |
To keep track (even if hopefully this is only in an old ember-data version and solved in most recent ones), I found I had this issue in unit tests for models (in maybe some edge cases where I do several unit tests on models extended with or without some model mixins), even when not using Working fix is to add import DS from 'ember-data';
function _preventSuperClassModelNamesDuplicates(factory) {
if (factory.superclass) {
factory.superclass.modelName = undefined;
_preventSuperClassModelNamesDuplicates(factory.superclass);
}
}
export default DS.Store.extend({
modelFor() {
const factory = this._super(...arguments);
_preventSuperClassModelNamesDuplicates(factory);
return factory;
}
}); |
copy of emberjs/ember.js#15268
failing test: #4999
The text was updated successfully, but these errors were encountered: