I want to create a property which represents an Object stringified. It should update whenever any sub property of the object changes even if it isnt a direct child.
I.e.
var obj = Ember.Object.extend({jsonString: Ember.something()}).create({foo: 1, bar: 2, baz: Ember.Object.create({bam: Ember.A([1, 2, 3])})});
expect(obj.get('jsonString')).to.equal('{"foo": 1, "bar": 2, "baz": {"bam": [1, 2, 3]}}');
obj.set('foo', 3);
expect(obj.get('jsonString')).to.equal('{"foo": 3, "bar": 2, "baz": {"bam": [1, 2, 3]}}');
obj.set('foo.baz.dd', 'test');
expect(obj.get('jsonString')).to.equal('{"foo": 3, "bar": 2, "baz": {"dd": "test", "bam": [1, 2, 3]}}');
Thanks!
Aucun commentaire:
Enregistrer un commentaire