Ember.computed - make property immutable


#1

Hi all,

it seems like this is something simple but im not able to find a straight forward solution to it.Any help is greatly appreciated.

I have the below function which works fine… but I need to add a property so I can save the original state of the array. I have put it below just to show a small visual of what I need, I understand the syntax and approach is wrong. Basically I need to copy the billing array to a new array where it wont be binded by the original computed value anymore. I hope I have described it properly.

billingContacts: Ember.computed(‘notifications’, function() { var notifications = this.get(‘notifications’); var billing = []; var newBilling = billing; if (notifications) {

        billing = notifications.find(function(item) {
            return /billing/i.test(item.name);
        });
    }
    return billing;
}),

#2

It’s not really clear what you’re asking here, can you try to explain in a different way?