-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Calling unregister
on the registry does not clear out the container
#11173
Comments
this appears to be a regression, as when implemented this did work. |
ping @dgeb as resolver refactor got merged |
@igorT What ember version are you working with? Where are you making these calls? In an application or application instance initializer? Are you sure you're working with a container? An updated example would be great - an updated failing test would be even better :) |
1.13.something last I checked. I'll update my issue/retest with the latest code next week |
I was thrown by the example in which you're calling |
@rwjblue this hasn't been addressed yet. There is now some complexity in registry / container relationships:
Because of this, communication up the possible chain of related registries to containers is not straightforward. For instance, a container might have received a registration from a fallback registry. If that registration is then reset on the fallback registry, would it be expected that a container's entries are cleared? How about if a new registration is added with the same key, but on the container's direct registry (not its fallback registry)? This would then replace the fallback registry's entry, but it's unclear whether previously instantiated objects should be cleared. The more I look at the problem of registry -> container notifications, the murkier it seems. The simple alternative is to call @igorT - although this isn't automatic, will this work for you? |
@dgeb Thanks for the container.reset tips! Not sure if it's the same issue but my problem was: • I register a new DS.Model (with a new adapter and a new serializer). Without |
Given the new owner concept, and the presence of both a container and registry in the owner I think that we could do the right thing when unregister() {
this.reset(...arguments);
this._super(...arguments);
} As long as |
I agree that the new owner concept provides a nice solution that was previously unavailable. After talking with @rwjblue, I'm going to prep a PR to add an |
`ApplicationInstance#unregister` now overrides `RegistryProxy#unregister` in order to clear any cached instances of the unregistered factory (via `__container__.reset()`). [Closes emberjs#11173]
Until the container/registry split, if you were in a test and wanted to stub methods or tap them for a particular class, you could have done the following:
However in the new world, calling unregister on the registry does not work, as we cache the factory when we look it up and calling unregister does not clear out container factoryCache.
cc @dgeb
To be clear I think that having registry know about the containers seems wrong, maybe we could bring back
unregister
on the container itself?The text was updated successfully, but these errors were encountered: