What is the difference between this.set and Ember.set

Is there a difference between the following two conditions this.set ('firstName', 'ember') and Ember.set (this, 'firstName', 'ember')

+4
source share
1 answer

Ember's chain of computed objects and observers rely on a call to object.set () on the object. You will often be warned about this if you forget.

However, you may find yourself in a situation where you cannot know if the object to which you were transferred is Ember.Object or just a simple javascript object. What Ember.set()comes in handy works on both types of objects.

const setFoo(target, value) {
    Ember.set(target, 'foo', value);
}

const a = {foo:null};
const b = Ember.Object.create({foo:null});

// both calls are valid because we use Ember.set()
setFoo(a, 'johnny');
setFoo(b, 'bravo');

Here's the official documentation that is useful to you: Ember.set ()

+3

Source: https://habr.com/ru/post/1674371/


All Articles