Reputation: 928
I have an ember-cli app using ember 1.11.1, ember-data 1.0.0-beta.16.1 & ember-cli 0.2.1
I have a serializer in app/serializers/role.js that I generated via ember g serializer Role
import DS from 'ember-data';
export default DS.RESTSerializer.extend({});
And I have an adapter in app/adapters/application.js:
import DS from 'ember-data';
export default DS.RESTAdapter.extend({namespace: 'api/1'});
When I load my app, the chrome ember inspector shows no sign of the serializer or adapter in the container section.
The correct code does appear in /assets/frontend/frontend.js
when I view source in the browser:
define('frontend/serializers/role', ['exports', 'ember-data'], function (exports, DS) {
'use strict';
exports['default'] = DS['default'].RESTSerializer.extend({});
});
define('frontend/adapters/application', ['exports', 'ember-data'], function (exports, DS) {
'use strict';
exports['default'] = DS['default'].RESTAdapter.extend({ namespace: "api/1" });
});
The Ember application boots up without errors except that when I try to add to and use the serializer, nothing works because it's not loaded and doesn't appear in the Ember container - even when I check application.registry._defaultContainer.cache
via the console.
I have another simple ember-cli app that does show the same adapter and serializer in the container but I can't figure out why it does and my other app doesn't.
Any idea why that might be? It's driving me nuts.
Upvotes: 0
Views: 277
Reputation: 2309
Serializers and Adapters are no longer singleton. I assume by looking at the content of the Container tab in the inspector, it only shows singleton objects.
When you say
when I try to add to and use the serializer, nothing works
How do you do this? The way to do it now is to access them via the store.
Basically how it works now is the store (store:main) is responsible for returning an Adapter and Serializer when asked. The first time it's asked it created the instance and every subsequent request returns that same single instance. The reason they aren't singleton is because a single store instance needs to maintain its own Adapters and Serializers - so if you have two stores you need to be able to create two 'Person' Adapters for example.
This Ember Forum discussion might help you a bit. This Pull Request is the implementation.
Upvotes: 1