The site I'm building uses multiple Ember apps to manage different areas of the site. It used to be easy to share models definitions between apps. One app would define the models (i.e. App1.Product
) and the other app (App2) could create them by calling createRecord on the model itself: App1.Product.createRecord({})
However, with Ember Data 1.0, all records are created off the store object. So this no longer works from App2:
App1.Product = DS.Model.extend({
name: DS.attr('string'),
price: DS.attr('number')
});
App2.IndexRoute = Ember.Route.extend({
setupController: function(controller, products) {
controller.set('products', [
// DOESN'T WORK
this.store.createRecord('product', {name: 'Robot', price: 10.55}),
this.store.createRecord('product', {name: 'Blocks', price: 4.99})
]);
}
});
This doesn't work since App2 doesn't have any Product model definitions defined on its namespace.
How can I share model definitions (and serializers and adapters) between apps now? The current hack I am doing is having a JS file that 'imports' all the shared models:
App2.Product = App1.Product;
But this gets tedious for a long list of models and adapters.
Is there a way to create a shell Ember application that the other apps inherit from? (instances of Ember.Application do not have an extend method).