This mixin is applied automatically to the Array class on page load, so you can use any of these methods on simple arrays. If Array already implements one of these methods, the mixin will not override them.
To make your own custom class enumerable, you need two items:
You must have a length property. This property should change whenever the number of items in your enumerable object changes. If you use this with an
Ember.Object subclass, you should be sure to change the length property using
You must implement
nextObject(). See documentation.
Once you have these two methods implemented, apply the
Ember.Enumerable mixin to your class and you will be able to enumerate the contents of your object like any other collection.
© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.