Skip to content
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

Simplify store.adapterFor and store.serializerFor. #5300

Merged
merged 4 commits into from
Dec 29, 2017

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Dec 22, 2017

  • Make adapter and serializer types singleton
  • Simplify adapterFor and serializerFor
  • Remove ContainerInstanceCache

Use an inline series of lookups (instead of `ContainerInstanceCache`)
This was previously being done by ContainerInstanceCache (when it would
look up an instance, it would always `set(instance, 'store', store)`),
but the DI system can already do this for us automatically.

This simplifies adapter / serializer testing quite a bit...
There is no reason to have them be non-singleton since we were
already caching in the `ContainerInstanceCache`...
@rwjblue
Copy link
Member Author

rwjblue commented Dec 22, 2017

I created a tracking issue (adopted-ember-addons/ember-data-model-fragments#285) in ember-data-model-fragments...

@rwjblue
Copy link
Member Author

rwjblue commented Dec 22, 2017

I chatted with @bmac offline, and there was some concern around the change making adapters and serializers singletons. Specifically, the move away from being singletons was done in order to support having different adapters and serializer instances with multiple store services (where each store got its own adapter and serializer instances). There were no tests to that effect, however it would be fairly easy to revert that small subsection here.

I am concerned about lack of proper test coverage if this is actually feature to the system...

@bmac
Copy link
Member

bmac commented Dec 22, 2017

@rwjblue Just reviewed it and this change looks good to me. I think we should land it without fce9eed. I just created #5301 to try to add a test for the behavior around adapters and serializers being singletons.

@bmac bmac merged commit e934b67 into emberjs:master Dec 29, 2017
@rwjblue rwjblue deleted the simplify-adapter-and-serializer-lookup branch December 29, 2017 01:29
rondale-sc added a commit to rondale-sc/ember-data-model-fragments that referenced this pull request Jan 26, 2018
Ember Data 3.0 removed the ContainerInstanceCache class which we were
(prior to this patch) monkey-patching to override the default serailizer
fallback lookup.

This PR goes back to a similar approach to what
ember-data-model-fragments was using prior to ember-data 2.11 (when
ContainerInstanceCache was added)

For a bit of context here is the patch that introduced the monkey-patch
for Ember Data 2.11:

adopted-ember-addons@a856c24

And here is the patch that remove ContainerInstanceCache class from
Ember Data making the aforementioned monkey patch throw in 3.0:

emberjs/data#5300

This PR ensures that the correct serializer is looked up as per the
tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants