|
1 |
| -You'll notice standard JavaScript class patterns and the new ES2015 |
2 |
| -classes aren't widely used in Ember. Plain objects can still be found, |
3 |
| -and sometimes they're referred to as "hashes". |
| 1 | +One of the first things you'll notice when you generate JavaScript files in Ember is that most of the code you will write goes inside of an object. While an Ember Object might look a lot like an ES2015 JavaScript class, it has some special properties. |
4 | 2 |
|
5 |
| -JavaScript objects don't support the observation of property value changes. |
6 |
| -Consequently, if an object is going to participate in Ember's binding |
7 |
| -system you may see an `Ember.Object` instead of a plain object. |
| 3 | +### Introducing: Ember Objects |
8 | 4 |
|
9 |
| -[Ember.Object](https://www.emberjs.com/api/ember/release/modules/@ember%2Fobject) also provides a class system, supporting features like mixins |
10 |
| -and constructor methods. Some features in Ember's object model are not present in |
11 |
| -JavaScript classes or common patterns, but all are aligned as much as possible |
12 |
| -with the language and proposed additions. |
| 5 | +The [Ember Object](https://www.emberjs.com/api/ember/release/classes/EmberObject) class extends plain JavaScript objects to provide core framework functions such as participating in Ember's [binding system](../object-model/bindings/) or how changes to an object automatically trigger updates to the user interface. |
13 | 6 |
|
14 |
| -Ember also extends the JavaScript `Array` prototype with its |
15 |
| -[Ember.Enumerable](https://emberjs.com/api/ember/2.15/classes/Ember.Enumerable) interface to provide change observation for arrays. |
| 7 | +Most objects in Ember, including Routes, Models, Services, Mixins, Controllers, and Components extend the `EmberObject` class. |
16 | 8 |
|
17 |
| -Finally, Ember extends the `String` prototype with a few [formatting and |
18 |
| -localization methods](https://www.emberjs.com/api/ember/release/classes/String). |
| 9 | +### Why Ember Objects? |
| 10 | + |
| 11 | +The most important reason is that an Ember Object can be watched for changes – or _observed_. For example, being [observable](https://www.emberjs.com/api/ember/release/classes/Observable) is important for [computed properties](../object-model/computed-properties/). It is one of the fundamental ways that models, controllers and views communicate with each other in an Ember application. |
| 12 | + |
| 13 | +### More on Ember Objects |
| 14 | + |
| 15 | +The [@ember/object](https://www.emberjs.com/api/ember/release/modules/@ember%2Fobject) package also provides a class system, supporting features like mixins and constructor methods, and being observable. |
| 16 | + |
| 17 | +Some features in Ember's object model are not present in JavaScript classes or common patterns, but all are aligned as much as possible with the language and proposed additions. |
| 18 | + |
| 19 | +Ember also extends the JavaScript `Array` prototype with its [@ember/enumerable](https://emberjs.com/api/ember/release/classes/Enumerable) interface to provide change observation for arrays. |
| 20 | + |
| 21 | +Finally, Ember extends the `String` prototype with a few [formatting and localization methods](https://www.emberjs.com/api/ember/release/classes/String). |
0 commit comments