Returns true
if the currently active item is the last item in the list.
Returns true
if the currently active item is the first item in the list.
Gets or sets the current active item in the list. NOTE: Only currently available items can be activated. For example, if you are using {@link module:models.withFiltering withFiltering} then items which have been filtered out can not be activated.
The item to activate. Must be present in the current list. To retrieve the currently active item, do not pass any arguments.
The currently active item.
Adds items to the ModelCollection.
The items to add to the ModelCollection.
Removes all items from the ModelCollection.
The name of the event to fire.
Optional arguments to pass to subscribers.
Returns false
if the bus is stopped. Otherwise,
returns a Promise that will resolve with an array of values returned by
event subscribers, or reject with the first Promise rejection or thrown error.
The set of items in the ModelCollection.
NOTE: Returns a shallow copy of the underlying collection. That means the array returned can be mutated without affecting the real ModelCollection, but all the items in the array are the same by reference, so mutating an object in the collection will also mutate the object stored in the ModelCollection.
Whether to wrap back to the start of the list if the currently active item is the last item.
The newly activated item, or null
if at end of list
and wrap
is not truthy.
Registers a subscriber for the given event. The subscriber will be invoked in the context used to create the EventBus and passed any arguments provided to the fire method.
The name of the event to listen for.
The subscriber to invoke when the event is fired.
Method to invoke to remove the subscriber.
Similar to on, except the subscriber will be removed as soon as it is invoked.
The name of the event to listen for.
The subscriber to invoke when the event is fired.
Method to invoke to remove the subscriber.
Whether to wrap back to the end of the list if the currently active item is the first item.
The newly activated item, or null
if at start of list
and wrap
is not truthy.
Removes items from the ModelCollection.
The items to remove from the ModelCollection.
Resumes notifying subscribers after stop was called. Any events fired before resuming are dropped entirely.
Stops notifying subscribers of fired events until resume is called.
Adds "active item" tracking and navigation to an existing ModelCollection instance.
Note on Grouping: If you want to navigate through a grouped list, you may want to ensure an order has been applied beforehand. Use {@link module:models.withOrdering withOrdering} and ensure your array of iteratees starts with your group selector. This ensures that navigating through the list correctly moves between groups.
{@link Events.ADDED}
{@link Events.REMOVED}
{@link Events.FILTER_CHANGED}
{@link Events.ACTIVE_CHANGED}