Class Ember.NativeArray
publicThe NativeArray mixin contains the properties needed to make the native
Array support Ember.MutableArray and all of its dependent APIs. Unless you
have EmberENV.EXTEND_PROTOTYPES
or EmberENV.EXTEND_PROTOTYPES.Array
set to
false, this will be applied automatically. Otherwise you can apply the mixin
at anytime by calling Ember.NativeArray.apply(Array.prototype)
.
@each public
Inherited from EmberArray packages/ember-runtime/lib/mixins/array.js:595
Returns a special object that can be used to observe individual properties on the array. Just get an equivalent property on this object and it will return an enumerable that maps automatically to the named key on the member objects.
@each
should only be used in a non-terminal context. Example:
myMethod: computed('posts.@each.author', function(){
...
});
If you merely want to watch for the array being changed, like an object being
replaced, added or removed, use []
instead of @each
.
myMethod: computed('posts.[]', function(){
...
});
[] public
Inherited from EmberArray packages/ember-runtime/lib/mixins/array.js:280
- returns
this
This is the handler for the special array content property. If you get this property, it will return this. If you set this property to a new array, it will replace the current content.
This property overrides the default property defined in Ember.Enumerable
.
firstObject Object public
Inherited from Enumerable packages/ember-runtime/lib/mixins/enumerable.js:133
- returns
- Object
the object or undefined
Helper method returns the first object from a collection. This is usually used by bindings and other parts of the framework to extract a single object if the enumerable contains only one item.
If you override this method, you should implement it so that it will
always return the same value each time it is called. If your enumerable
contains only one object, this method should always return that object.
If your enumerable is empty, this method should return undefined
.
let arr = ['a', 'b', 'c'];
arr.get('firstObject'); // 'a'
let arr = [];
arr.get('firstObject'); // undefined
hasArrayObservers public
Inherited from EmberArray packages/ember-runtime/lib/mixins/array.js:499
Becomes true whenever the array currently has observers watching changes on the array.
lastObject Object public
Inherited from Enumerable packages/ember-runtime/lib/mixins/enumerable.js:170
- returns
- Object
the last object or undefined
Helper method returns the last object from a collection. If your enumerable
contains only one object, this method should always return that object.
If your enumerable is empty, this method should return undefined
.
let arr = ['a', 'b', 'c'];
arr.get('lastObject'); // 'c'
let arr = [];
arr.get('lastObject'); // undefined
length public
Inherited from EmberArray packages/ember-runtime/lib/mixins/array.js:213
Required. You must implement this method to apply this mixin.
Your array must support the length
property. Your replace methods should
set this property whenever it changes.