import Enumerable from '@ember/enumerable';
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.
Writing Your Own Enumerable
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.Objectsubclass, you should be sure to change the length property using
You must implement
Once you have these two methods implemented, apply the
to your class and you will be able to enumerate the contents of your object
like any other collection.
Using Ember Enumeration with Other Libraries