vendredi 15 avril 2016

Inject aditional data to ember model

I want inject current user to my topic model and make some checks.

Example:

export default DS.Model.extend({
    currentUser: Ember.inject.service('session-account'),
    text: DS.belongsTo('string'),
    userId:   DS.attr('number'),
    isMine: function(){
        return this.get('currentUser.data.id') == this.get('userId')
    }.property()
}

Question: Is it preferable approach to do this logic? Also I'm interesting about performance of this approach, inject service to each row may cause performance degradation?




Aucun commentaire:

Enregistrer un commentaire