Quantcast
Viewing all articles
Browse latest Browse all 4827

How to make removeObject KVO-compliant?

@kfuzaylov wrote:

I have model

import DS from 'ember-data';

export default DS.Model.extend({
	Structure: DS.attr('raw'),
});

So, structure is array of objects

[{
    type: 'comp-a',
    children: [
        {type: 'comp-b'},
        {type: 'comp-b'}
    ]
}]

Next, i print this structure

structure: Ember.computed('model.Structure', function() {
    var st = this.get('model.Structure');
    // handle this structure

    return st;
});

{{#each structure as |item|}}
	{{component item.type}}
{{/each}}

Question. When I push object to comp-a, Ember renders new pushed component

this.get('model.Structure')[0].children.pushObject({
    type: 'comp-b'
});

But, when I remove any object it doesn't.

var child = this.get('model.Structure')[0].children[0];
this.get('model.Structure')[0].children.removeObject(child);

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles