Skip to content

Commit

Permalink
Support custom stores defined on the container as
Browse files Browse the repository at this point in the history
  • Loading branch information
bmac committed Jun 12, 2015
1 parent 1dc03ca commit 8b94b49
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/ember-data/lib/initializers/store-injections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@param {Ember.Registry} registry
*/
export default function initializeStoreInjections(registry) {
registry.injection('controller', 'store', 'store:application');
registry.injection('route', 'store', 'store:application');
registry.injection('data-adapter', 'store', 'store:application');
registry.injection('controller', 'store', 'store:main');
registry.injection('route', 'store', 'store:main');
registry.injection('data-adapter', 'store', 'store:main');
}
8 changes: 4 additions & 4 deletions packages/ember-data/lib/initializers/store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {JSONSerializer, RESTSerializer} from "ember-data/serializers";
import {RESTAdapter} from "ember-data/adapters";
import ContainerProxy from "ember-data/system/container-proxy";
import Store from "ember-data/system/store";

/**
Configures a registry for use with an Ember-Data
Expand All @@ -18,16 +17,17 @@ export default function initializeStore(registry, application) {
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });

registry.register('store:application', application && application.Store || Store);
if (application && application.Store) {
registry.register('store:application', application.Store);
}

// allow older names to be looked up

var proxy = new ContainerProxy(registry);
proxy.registerDeprecations([
{ deprecated: 'serializer:_default', valid: 'serializer:-default' },
{ deprecated: 'serializer:_rest', valid: 'serializer:-rest' },
{ deprecated: 'adapter:_rest', valid: 'adapter:-rest' },
{ deprecated: 'store:main', valid: 'store:application' }
{ deprecated: 'adapter:_rest', valid: 'adapter:-rest' }
]);

// new go forward paths
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Store from "ember-data/system/store";
/**
Configures a registry for use with an Ember-Data
store.
Expand All @@ -24,7 +25,14 @@ export default function initializeStoreService(applicationOrRegistry) {
container = registry;
}
}
if (registry.has('store:application')) {
var customStoreFactory = container.lookupFactory('store:application');
registry.register('service:main', customStoreFactory);
} else {
registry.register('store:main', Store);
}

// Eagerly generate the store so defaultStore is populated.
var store = container.lookup('store:application');
var store = container.lookup('store:main');
registry.register('service:store', store, { instantiate: false });
}
4 changes: 4 additions & 0 deletions packages/ember-data/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if (Ember.VERSION.match(/^1\.[0-7]\./)) {
". Please upgrade your version of Ember, then upgrade Ember Data");
}

if (Ember.VERSION.match(/^1\.12\.0/)) {
throw new Ember.Error("Ember Data does not work with Ember 1.12.0. Please upgrade to Ember 1.12.1 or higher.");
}

// support RSVP 2.x via resolve, but prefer RSVP 3.x's Promise.cast
Ember.RSVP.Promise.cast = Ember.RSVP.Promise.cast || Ember.RSVP.resolve;

Expand Down

0 comments on commit 8b94b49

Please sign in to comment.