Fork me on GitHub
Show:

SubsetCollection

Summary

A collection which acts as a subset of another (source) collection.

A SubsetCollection defines rules for filtering models from a source collection. The SubsetCollection will sync to all changes in the source collection. If filtered rules are changed on the SubsetCollection, it will be updated with models from the soure collection accordingly

Constructor

aeris.SubsetCollection

Syntax

aeris.SubsetCollection

(
  • sourceCollection
  • opt_options
)

Summary

Parameters:

Methods

_prepareModel

Inherited from Backbone.Collection but overwritten in ../src/collection.js:122

Syntax

_prepareModel

() private

Summary

Pass modelOptions on to newly created models.

add

Syntax

add

(
  • models
)

Summary

Add models to the collection.

Parameters:

at

Syntax

at

(
  • index
)
Model

Summary

Retrieve a model from the collection by index.

Parameters:

Returns:

bindToSourceCollection_

Syntax

bindToSourceCollection_

() private

Summary

fetch

Syntax

fetch

(
  • opt_options
)
Promise

Summary

Fetches data from the underlying source collection.

Parameters:

Returns:

getFilteredSourceModels_

Syntax

getFilteredSourceModels_

() Array.<Model> protected

Summary

Returns:

Array.<Model>:

Models from the source collection which pass subset filtering rules.

getSourceCollection

Syntax

getSourceCollection

() Collection

Summary

Returns:

isOverLimit

Syntax

isOverLimit

() Boolean

Summary

Returns:

isUnderLimit

Syntax

isUnderLimit

() Boolean

Summary

Does the collection have fewer models than the specified limit?

If no limit is set, this will always return true.

Returns:

isValid

Syntax

isValid

() Boolean=

Summary

Runs validation on all collection models.

Returns:

Boolean=:

Returns false if any model fails validation.

normalizeSourceCollection_

Syntax

normalizeSourceCollection_

() private

Summary

parse

Syntax

parse

() protected

Summary

pop

Syntax

pop

() protected

Summary

proxyRequestEvents_

Syntax

proxyRequestEvents_

() private

Summary

push

Syntax

push

() protected

Summary

remove

Syntax

remove

(
  • models
)

Summary

Remove models from the collection.

Parameters:

removeFilter

Syntax

removeFilter

()

Summary

Stops filtering models from the source collection.

removeLimit

Syntax

removeLimit

()

Summary

Stops limiting the number of models from the source collection to set on the SubsetCollection.

reset

Syntax

reset

(
  • opt_models
)

Summary

Remove and replace all models in the collection.

Parameters:

resetToSourceModel_

Syntax

resetToSourceModel_

() private

Summary

set

Syntax

set

() protected

Summary

setFilter

Syntax

setFilter

(
  • filter
  • opt_ctx
)

Summary

Sets a filter to be used when syncing the SubsetCollection to it's source collection.

The filter receives a source collection models as an argument. If the filter returns true, the model will be added to the SubsetCollection.

Set the filter to null to disable filtering.

Parameters:

setLimit

Syntax

setLimit

(
  • limit
)

Summary

Limits the number of models from the source collection to set on the SubsetCollection.

Parameters:

shift

Syntax

shift

() protected

Summary

slice

Syntax

slice

() protected

Summary

Properties

filter_

Syntax

filter_

?function():Boolean private

Summary

length

Syntax

length

Unknown

Summary

The number of models in the collection.

limit_

Syntax

limit_

?number If null, no limit is enforced. protected

Summary

model

Syntax

model

Function

Summary

modelOptions_

Syntax

modelOptions_

Object protected

Summary

Options to pass on to models created by this collection.

Events

add

Syntax

add

Summary

When a model is added to the {aeris.Collection}.

Event Payload:

change

Syntax

change

Summary

When any child model's attribute changes

Event Payload:

change:[attribute]

Syntax

change:[attribute]

Summary

When any child model's attribute changes, where [attribute] is the name of the attribute.

Event Payload:

remove

Syntax

remove

Summary

When a model is removed from the {aeris.Collection}.

Event Payload: