Extending models from a ember addon


#1

I have broken my application in three “fp-desktop”, “fp-mobile” and “fp-common”.

The models shared between the “fp-mobile” and “fp-desktop” applications are in most cases identical. So I figured I could inherit each model from a common ember-cli addon.

Like so:

fp-common/addon/models/address.js

 import DS from 'ember-data';
 var attr = DS.attr;
 export default DS.Model.extend({
   lineOne: attr('string'),
   city: attr('string'),
   state: attr('string'),
   zip: attr('string'),
});

fp-mobile/models/address.js

import Address from 'fp-common/models/address';
export default Address;

fp-desktop/models/address.js

import Address from 'fp-common/models/address';
export default Address.extend({
  desktopOnlyProperty: true
});

It seemed to work and then I started noticing strange things.

DirtyTracking of relationships stopped working and the ember inspector shows two of every model type. Eventually the count would diverge between the two model types.

I was thinking the modules defined in the addon were namespaced but perhaps not. What am I missing?

version info:

ember-cli 0.1.4 ember: 1.10.0-beta.1+canary.31667d05 ember-data: canary