Class: ddpReactiveCollection

ddpReactiveCollection

A reactive collection class.

new ddpReactiveCollection (ddpCollection, skiplimit)

Name Type Default Description
ddpCollection ddpCollection

Instance of @see ddpCollection class.

skiplimit Object {skip:0,limit:Infinity} optional

Object for declarative reactive collection slicing.

Classes

ddpReactiveCollection

Methods

_updateReactiveObjects ()

Sends new object state for every associated reactive object.

count ()Object

Reactive length of the local collection.

Returns:
Type Description
Object
  • Object with reactive length of the local collection. {result}

data ()Array

Returns reactive local collection with applied sorting, skip and limit. This returned array is being mutated within this class instance.

Returns:
Type Description
Array
  • Local collection with applied sorting, skip and limit.

map (f)ddpReducer

Maps reactive local collection to another reactive array. Specified function form https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map.

Name Type Description
f function

Function that produces an element of the new Array.

Returns:
Type Description
ddpReducer
  • Object that allows to get reactive mapped data @see ddpReducer.

onChange (f)

Runs a function every time a change occurs.

Name Type Description
f function

Function which recieves new collection at each change.

one (settings)ddpReactiveDocument

Returns a reactive object which fields are always the same as the first object in the collection.

Name Type Default Description
settings Object {preserve:false} optional

Settings for reactive object. Use {preserve:true} if you want to keep object on remove.

Returns:
Type Description
ddpReactiveDocument
  • Object that allows to get reactive object based on reduced reactive local collection @see ddpReactiveDocument.

reduce (f, initialValue)ddpReducer

Reduces reactive local collection. Specified function form https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce.

Name Type Description
f function

Function to execute on each element in the array.

initialValue *

Value to use as the first argument to the first call of the function.

Returns:
Type Description
ddpReducer
  • Object that allows to get reactive object based on reduced reactive local collection @see ddpReducer.

settings (skiplimit)

Update ddpReactiveCollection settings.

Name Type Default Description
skiplimit Object {skip:0,limit:Infinity} optional

Object for declarative reactive collection slicing.

sort (f)this

Sorts local collection according to specified function. Specified function form https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort.

Name Type Description
f function

A function used for sorting.

Returns:
Type Description
this

start ()

Start reactivity. This method is being called on instance creation. Also starts every associated reactive object.

stop ()

Stops reactivity. Also stops associated reactive objects.