Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember.Object

Marten
September 14, 2016

 Ember.Object

Marten

September 14, 2016
Tweet

More Decks by Marten

Other Decks in Technology

Transcript

  1. extend Gives you the ability to do classical inheritance class

    Person extends Object { say(script) { return `${this.name} says: "${script}"`; } } const Person = Ember.Object.extend({ say(script) { return `${this.name} says: "${script}"`; } });
  2. create Instantiates a new instance const Person = Ember.Object.extend({ say(script)

    { return `${this.name} says: "${script}"`; } }); let tom = Person.create({ name: 'Tom' }); tom.name // -> 'Tom' tom.say('Hello World'); // -> 'Tom says: "Hello World"'
  3. class Person { fullName() { return `${this.firstName} ${this.lastName}`; } });

    let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  4. class Person { fullName() { return `${this.firstName} ${this.lastName}`; } });

    let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom'
  5. class Person { fullName() { return `${this.firstName} ${this.lastName}`; } });

    let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale'
  6. class Person { fullName() { return `${this.firstName} ${this.lastName}`; } });

    let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale' tom.fullName // -> function () { }
  7. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  8. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom'
  9. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale'
  10. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale' tom.fullName // -> 'Tom Dale'
  11. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ });
  12. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.firstName // -> 'Tom'
  13. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.firstName // -> 'Tom' tom.lastName // -> 'Dale'
  14. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.firstName // -> 'Tom' tom.lastName // -> 'Dale' tom.fullName // -> ComputedProperty { … }
  15. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ });
  16. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('firstName') // -> 'Tom'
  17. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('firstName') // -> 'Tom' tom.get(‘lastName') // -> 'Dale'
  18. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('firstName') // -> 'Tom' tom.get(‘lastName') // -> 'Dale' tom.get('fullName') // -> 'Tom Dale'
  19. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  20. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.fullName // -> 'Tom Dale'
  21. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.fullName // -> 'Tom Dale' tom.firstName = ‘Tomster’;
  22. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.fullName // -> 'Tom Dale' tom.firstName = ‘Tomster’; tom.fullName // -> 'Tomster Dale'
  23. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ });
  24. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale'
  25. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale' tom.firstName = ‘Tomster’
  26. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale' tom.firstName = ‘Tomster’ tom.get('fullName') // -> 'Tom Dale'
  27. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ });
  28. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale'
  29. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale' tom.set(‘firstName’, ‘Tomster’)
  30. const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return

    `${this.firstName} ${this.lastName}`; }) }); let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.get('fullName') // -> 'Tom Dale' tom.set(‘firstName’, ‘Tomster’) tom.get('fullName') // -> 'Tomster Dale'
  31. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  32. tom.get('fullName') // -> TypeError: tom.get is not a function class

    Person { get fullName() { return `${this.firstName} ${this.lastName}`; } }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  33. Ember.Observable import Ember from 'ember'; export default Mixin.create({ get(keyName) {

    return Ember.get(this, keyName); }, set(keyName, value) { return Ember.set(this, keyName, value); } });
  34. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  35. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’firstName') // -> 'Tom'
  36. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’firstName') // -> 'Tom' Ember.get(tom, ’lastName’) // -> 'Dale'
  37. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’firstName') // -> 'Tom' Ember.get(tom, ’lastName’) // -> 'Dale' Ember.get(tom, ’fullName’) // -> 'Tom Dale'
  38. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  39. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’fullName') // -> 'Tom Dale'
  40. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’fullName') // -> 'Tom Dale' Ember.set(tom, ’firstName’, ‘Tomster’)
  41. class Person { get fullName() { return `${this.firstName} ${this.lastName}`; }

    }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; Ember.get(tom, ’fullName') // -> 'Tom Dale' Ember.set(tom, ’firstName’, ‘Tomster’) Ember.get(tom, ’fullName') // -> 'Tomster Dale'
  42. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); const

    Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }) });
  43. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.set(‘fullName’,

    ‘Yehuda Katz’) const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }) });
  44. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.set(‘fullName’,

    ‘Yehuda Katz’) const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }) }); Ember.get(tom, ’fullName') // -> ‘Yehuda Katz'
  45. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.set(‘fullName’,

    ‘Yehuda Katz’) const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }) }); Ember.get(tom, ’fullName') // -> ‘Yehuda Katz' tom.fullName // -> ‘Yehuda Katz'
  46. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); const

    Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }).readOnly() });
  47. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); tom.set(‘fullName’,

    ‘Yehuda Katz’) // -> Cannot set read-only property "fullName" const Person = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, function() { return `${this.firstName} ${this.lastName}`; }).readOnly() });
  48. let tom = Person.create({ fullName: ‘Tom Dale’ }); const Person

    = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, { get() { return `${this.firstName} ${this.lastName}`; }, set(key, value) { let [firstName, lastName] = value.split(/ /); this.firstName = firstName; this.lastName = lastName; return value; } }) });
  49. let tom = Person.create({ fullName: ‘Tom Dale’ }); const Person

    = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, { get() { return `${this.firstName} ${this.lastName}`; }, set(key, value) { let [firstName, lastName] = value.split(/ /); this.firstName = firstName; this.lastName = lastName; return value; } }) }); Ember.get(tom, ’firstName') // -> 'Tom'
  50. let tom = Person.create({ fullName: ‘Tom Dale’ }); const Person

    = Ember.Object.extend({ fullName: Ember.computed(‘firstName’, ‘lastName’, { get() { return `${this.firstName} ${this.lastName}`; }, set(key, value) { let [firstName, lastName] = value.split(/ /); this.firstName = firstName; this.lastName = lastName; return value; } }) }); Ember.get(tom, ’firstName') // -> 'Tom' Ember.get(tom, ’lastName’) // -> 'Dale'
  51. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  52. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); Ember.get(keyword, ’value') // -> ‘Un petit cheval' let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  53. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); Ember.get(keyword, ’value') // -> ‘Un petit cheval' let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’)
  54. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); Ember.get(keyword, ’value') // -> ‘Un petit cheval' let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse'
  55. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  56. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’)
  57. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse'
  58. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’)
  59. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, function() { let local

    = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’) Ember.get(keyword, ’value') // -> ‘A small horse'
  60. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘en’, ‘fr’, function() {

    let local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  61. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘en’, ‘fr’, function() {

    let local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’)
  62. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘en’, ‘fr’, function() {

    let local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse'
  63. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘en’, ‘fr’, function() {

    let local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’)
  64. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘en’, ‘fr’, function() {

    let local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’) Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’) Ember.get(keyword, ’value') // -> ‘A medium horse'
  65. const Keyword = Ember.Object.extend({ value: Ember.computed(‘locale’, ‘????????’, function() { let

    local = Ember.get(this, ‘locale’); return Ember.get(this, locale); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  66. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  67. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.set(keyword, ’locale’, ‘en’)
  68. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’locale’, ‘en’)
  69. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’) Ember.set(keyword, ’locale’, ‘en’)
  70. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.get(keyword, ’value') // -> ‘A small horse' Ember.set(keyword, ’en’, ‘A medium horse’) Ember.get(keyword, ’value') // -> ‘A medium horse' Ember.set(keyword, ’locale’, ‘en’)
  71. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  72. const Keyword = Ember.Object.extend({ localeChanged: Ember.observer(‘locale’, function() { let currentLocale

    = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.get(keyword, ’value') // -> undefined
  73. const Keyword = Ember.Object.extend({ init() { this.localeChanged(); }, localeChanged: Ember.observer(‘locale’,

    function() { let currentLocale = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ });
  74. const Keyword = Ember.Object.extend({ init() { this.localeChanged(); }, localeChanged: Ember.observer(‘locale’,

    function() { let currentLocale = Ember.get(this, ‘locale’); let cp = Ember.computed(currentLocale, function() { return Ember.get(this, currentLocale); }); Ember.defineProperty(this, ’value’, cp); }) }); let keyword = Keyword.create({ en: ‘A small horse’, fr: ‘Un petit cheval’, locale: ‘fr’ }); Ember.get(keyword, ’value') // -> ‘Un petit cheval'
  75. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); const SuperPerson = Ember.Object.extend({ init() { this.powerLevel = 90001; } });
  76. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); Ember.get(goku, ’friends') // -> undefined const SuperPerson = Ember.Object.extend({ init() { this.powerLevel = 90001; } });
  77. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); Ember.get(goku, ’friends') // -> undefined const SuperPerson = Ember.Object.extend({ init() { this.powerLevel = 90001; } }); Ember.get(goku, ’powerLevel') // -> 9001
  78. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); const SuperPerson = Ember.Object.extend({ init() { this._super(…arguments); this.powerLevel = 90001; } });
  79. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); Ember.get(goku, ’friends') // -> [] const SuperPerson = Ember.Object.extend({ init() { this._super(…arguments); this.powerLevel = 90001; } });
  80. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); let goku = SuperPerson.create(); Ember.get(goku, ’friends') // -> [] const SuperPerson = Ember.Object.extend({ init() { this._super(…arguments); this.powerLevel = 90001; } }); Ember.get(goku, ’powerLevel') // -> 9001
  81. const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }

    }); const Person = Ember.Object.extend({ friends: Ember.A(); }); vs
  82. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ });
  83. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> []
  84. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> []
  85. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom)
  86. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom) Ember.get(yehuda, ’friends') // -> [tom]
  87. const Person = Ember.Object.extend({ friends: Ember.A(); }); let tom =

    Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom) Ember.get(tom, ’friends') // -> [tom] Ember.get(yehuda, ’friends') // -> [tom]
  88. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  89. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  90. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  91. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  92. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom) Ember.get(yehuda, ’friends') // -> [tom] const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  93. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [] Ember.get(yehuda, ’friends’).push(tom) Ember.get(tom, ’friends') // -> [] Ember.get(yehuda, ’friends') // -> [tom] const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  94. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  95. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).push(tom) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); } });
  96. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); });
  97. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).push({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); });
  98. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).push({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); }); Ember.get(yehuda, ’friends') // -> [{ friend: tom, bff: true }]
  99. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).push({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); }); Ember.get(yehuda, ’friends') // -> [{ friend: tom, bff: true }] Ember.get(yehuda, ’bffs') // -> []
  100. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); });
  101. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).pushObject({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); });
  102. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).pushObject({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); }); Ember.get(yehuda, ’friends') // -> [{ friend: tom, bff: true }]
  103. let tom = Person.create({ firstName: ‘Tom’, lastName: ‘Dale’ }); let

    yehuda = Person.create({ firstName: ‘Yehuda’, lastName: ‘Katz’ }); Ember.get(yehuda, ’friends’).pushObject({ friend: tom, bff: true }) const Person = Ember.Object.extend({ init() { this.friends = Ember.A(); }, bffs: Ember.computed.filterBy(‘friends’, ‘bff’, true); }); Ember.get(yehuda, ’friends') // -> [{ friend: tom, bff: true }] Ember.get(yehuda, ’bffs') // -> [{ friend: tom, bff: true }]
  104. class Person { @computed(‘firstName’, ‘lastName’) get fullName() { return `${this.firstName}

    ${this.lastName}`; } }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’;
  105. class Person { @computed(‘firstName’, ‘lastName’) get fullName() { return `${this.firstName}

    ${this.lastName}`; } }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom'
  106. class Person { @computed(‘firstName’, ‘lastName’) get fullName() { return `${this.firstName}

    ${this.lastName}`; } }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale'
  107. class Person { @computed(‘firstName’, ‘lastName’) get fullName() { return `${this.firstName}

    ${this.lastName}`; } }); let tom = new Person(); tom.firstName = ‘Tom’; tom.lastName = ‘Dale’; tom.firstName // -> 'Tom' tom.lastName // -> 'Dale' tom.fullName // -> 'Tom Dale'