Class CoreObject public
import CoreObject from '@ember/object/core';CoreObject is the base class for all Ember constructs. It establishes a
class system based on Ember's Mixin system, and provides the basis for the
Ember Object Model. CoreObject should generally not be used directly,
instead you should use EmberObject.
Usage
You can define a class by extending from CoreObject using the extend
method:
const Person = CoreObject.extend({
  name: 'Tomster',
});For detailed usage, see the Object Model section of the guides.
Usage with Native Classes
Native JavaScript class syntax can be used to extend from any CoreObject
based class:
class Person extends CoreObject {
  init() {
    super.init(...arguments);
    this.name = 'Tomster';
  }
}Some notes about class usage:
- newsyntax is not currently supported with classes that extend from- EmberObjector- CoreObject. You must continue to use the- createmethod when making new instances of classes, even if they are defined using native class syntax. If you want to use- newsyntax, consider creating classes which do not extend from- EmberObjector- CoreObject. Ember features, such as computed properties and decorators, will still work with base-less classes.
- Instead of using this._super(), you must use standardsupersyntax in native classes. See the MDN docs on classes for more details.
- Native classes support using constructors
to set up newly-created instances. Ember uses these to, among other things,
support features that need to retrieve other entities by name, like Service
injection and getOwner. To ensure your custom instance setup logic takes place after this important work is done, avoid using theconstructorin favor ofinit.
- Properties passed to createwill be available on the instance by the timeinitruns, so any code that requires these values should work at that time.
- Using native classes, and switching back to the old Ember Object model is fully supported.
Methods
destroy : EmberObject public
Defined in packages/@ember/object/core.ts:538
- returns
- EmberObject
- receiver 
Destroys an object by setting the isDestroyed flag and removing its
metadata, which effectively destroys observers and bindings.
If you try to set a property on a destroyed object, an exception will be raised.
Note that destruction is scheduled for the end of the run loop and does not happen immediately. It will set an isDestroying flag immediately.
init public
Defined in packages/@ember/object/core.ts:319
An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition.
Example:
import EmberObject from '@ember/object';
const Person = EmberObject.extend({
  init() {
    alert(`Name is ${this.get('name')}`);
  }
});
let steve = Person.create({
  name: 'Steve'
});
// alerts 'Name is Steve'.NOTE: If you do override init for a framework class like Component
from @ember/component, be sure to call this._super(...arguments)
in your init declaration!
If you don't, Ember may not have an opportunity to
do important setup work, and you'll see strange behavior in your
application.
toString : String public
Defined in packages/@ember/object/core.ts:573
- returns
- String
- string representation 
Returns a string representation which attempts to provide more information
than Javascript's toString typically does, in a generic way for all Ember
objects.
import EmberObject from '@ember/object';
const Person = EmberObject.extend();
person = Person.create();
person.toString(); //=> "<Person:ember1024>"If the object's class is not defined on an Ember namespace, it will indicate it is a subclass of the registered superclass:
const Student = Person.extend();
let student = Student.create();
student.toString(); //=> "<(subclass of Person):ember1025>"If the method toStringExtension is defined, its return value will be
included in the output.
const Teacher = Person.extend({
  toStringExtension() {
    return this.get('fullName');
  }
});
teacher = Teacher.create();
teacher.toString(); //=> "<Teacher:ember1026:Tom Dale>"willDestroy public
Defined in packages/@ember/object/core.ts:565
Override to implement teardown.
Properties
concatenatedProperties public
Defined in packages/@ember/object/core.ts:353
Defines the properties that will be concatenated from the superclass (instead of overridden).
By default, when you extend an Ember class a property defined in
the subclass overrides a property with the same name that is defined
in the superclass. However, there are some cases where it is preferable
to build up a property's value by combining the superclass' property
value with the subclass' value. An example of this in use within Ember
is the classNames property of Component from @ember/component.
Here is some sample code showing the difference between a concatenated property and a normal one:
import EmberObject from '@ember/object';
const Bar = EmberObject.extend({
  // Configure which properties to concatenate
  concatenatedProperties: ['concatenatedProperty'],
  someNonConcatenatedProperty: ['bar'],
  concatenatedProperty: ['bar']
});
const FooBar = Bar.extend({
  someNonConcatenatedProperty: ['foo'],
  concatenatedProperty: ['foo']
});
let fooBar = FooBar.create();
fooBar.get('someNonConcatenatedProperty'); // ['foo']
fooBar.get('concatenatedProperty'); // ['bar', 'foo']This behavior extends to object creation as well. Continuing the above example:
let fooBar = FooBar.create({
  someNonConcatenatedProperty: ['baz'],
  concatenatedProperty: ['baz']
})
fooBar.get('someNonConcatenatedProperty'); // ['baz']
fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz']Adding a single property that is not an array will just add it in the array:
let fooBar = FooBar.create({
  concatenatedProperty: 'baz'
})
view.get('concatenatedProperty'); // ['bar', 'foo', 'baz']Using the concatenatedProperties property, we can tell Ember to mix the
content of the properties.
In Component the classNames, classNameBindings and
attributeBindings properties are concatenated.
This feature is available for you to use throughout the Ember object model, although typical app developers are likely to use it infrequently. Since it changes expectations about behavior of properties, you should properly document its usage in each individual concatenated property (to not mislead your users to think they can override the property in a subclass).
isDestroyed public
Defined in packages/@ember/object/core.ts:502
Destroyed object property flag.
if this property is true the observers and bindings were already
removed by the effect of calling the destroy() method.
isDestroying public
Defined in packages/@ember/object/core.ts:520
Destruction scheduled flag. The destroy() method has been called.
The object stays intact until the end of the run loop at which point
the isDestroyed flag is set.
mergedProperties public
Defined in packages/@ember/object/core.ts:427
Defines the properties that will be merged from the superclass (instead of overridden).
By default, when you extend an Ember class a property defined in
the subclass overrides a property with the same name that is defined
in the superclass. However, there are some cases where it is preferable
to build up a property's value by merging the superclass property value
with the subclass property's value. An example of this in use within Ember
is the queryParams property of routes.
Here is some sample code showing the difference between a merged property and a normal one:
import EmberObject from '@ember/object';
const Bar = EmberObject.extend({
  // Configure which properties are to be merged
  mergedProperties: ['mergedProperty'],
  someNonMergedProperty: {
    nonMerged: 'superclass value of nonMerged'
  },
  mergedProperty: {
    page: { replace: false },
    limit: { replace: true }
  }
});
const FooBar = Bar.extend({
  someNonMergedProperty: {
    completelyNonMerged: 'subclass value of nonMerged'
  },
  mergedProperty: {
    limit: { replace: false }
  }
});
let fooBar = FooBar.create();
fooBar.get('someNonMergedProperty');
// => { completelyNonMerged: 'subclass value of nonMerged' }
//
// Note the entire object, including the nonMerged property of
// the superclass object, has been replaced
fooBar.get('mergedProperty');
// => {
//   page: {replace: false},
//   limit: {replace: false}
// }
//
// Note the page remains from the superclass, and the
// `limit` property's value of `false` has been merged from
// the subclass.This behavior is not available during object create calls. It is only
available at extend time.
In Route the queryParams property is merged.
This feature is available for you to use throughout the Ember object model, although typical app developers are likely to use it infrequently. Since it changes expectations about behavior of properties, you should properly document its usage in each individual merged property (to not mislead your users to think they can override the property in a subclass).