vendredi 20 mars 2015

Ember data - Multiple namespaces for single model

I have an Ember data model named Activity.


Depending on my current route, I need to call services to populate the store with activities from different API namespaces. So while my current ActivityAdapter looks like this:



App.ActivityAdapter = DS.RESTAdapter.extend({
namespace: 'services/activities'
});


I really want it to look like this:



App.ActivityAdapter = DS.RESTAdapter.extend({
if (this.get('currentRoute') === "user") {
namespace: 'services/users/activities'
} else {
namespace: 'services/activities'
}
});


I can't seem to find a solution for this, and the best I can think of right now is a hack that involves creating a separate UserActivity model that basically has the same properties as the Activity model, and then specifying a separate UserActivityAdapter.


Has anyone else run into this issue? Any input is appreciated!





Aucun commentaire:

Enregistrer un commentaire