#ReactiveList Provides a simple reactive list interface
-
Arguments
- Example:
var list = new ReactiveList();
list.insert(1, { text: 'Hello id: 1' });
list.insert(2, { text: 'Hello id: 2' });
list.insert(3, { text: 'Hello id: 3' });
list.update(2, { text: 'Updated 2'});
list.remove(1);
list.forEach(function(value, key) {
console.log('GOT: ' + value.text);
}, true); // Set noneReactive = true, default behaviour is reactive
// Return from Template:
Template.hello.list = function() {
return list.fetch();
};
####Example of a sort algorithm Sort can be used to define the order of the list
var list = new ReactiveList({
sort: function(a, b) {
// a and b are type of { key, value }
// here we sort by the key:
return a.key < b.key;
}
});
###Object chain
first last
undefined - obj - obj - obj - undefined
(prev value next) (prev value next) (prev value next)
ReactiveList = function(options) { ...
reactive-list.js:46
-
-
This method length is defined in prototype
of ReactiveList
Returns {number} (is reactive) Length of the reactive list
ReactiveList.prototype.length = function() { ...
reactive-list.js:73
-
-
This method reset is defined in prototype
of ReactiveList
ReactiveList.prototype.reset = function() { ...
reactive-list.js:83
-
-
This method update is defined in prototype
of ReactiveList
Arguments
-
ReactiveList.prototype.update = function(key, value) { ...
reactive-list.js:102
-
-
This method insert is defined in prototype
of ReactiveList
Arguments
-
ReactiveList.prototype.insert = function(key, value) { ...
reactive-list.js:118
-
-
This method remove is defined in prototype
of ReactiveList
Arguments
-
ReactiveList.prototype.remove = function(key) { ...
reactive-list.js:180
-
-
This method getLastItem is defined in prototype
of ReactiveList
Returns {any} Pops last item from the list - removes the item from the list
ReactiveList.prototype.getLastItem = function(first) { ...
reactive-list.js:221
-
-
This method getFirstItem is defined in prototype
of ReactiveList
Returns {any} Pops first item from the list - removes the item from the list
ReactiveList.prototype.getFirstItem = function() { ...
reactive-list.js:239
-
-
This method forEach is defined in prototype
of ReactiveList
Arguments
funciton(value, key)
forEachReverse
-
ReactiveList.prototype.forEach = function(f, noneReactive, reverse) { ...
reactive-list.js:249
-
-
This method forEachReverse is defined in prototype
of ReactiveList
Arguments
funciton(value, key)
-
ReactiveList.prototype.forEachReverse = function(f, noneReactive) { ...
reactive-list.js:272
-
-
This method fetch is defined in prototype
of ReactiveList
Arguments
-
Returns {array} (is reactive) List of items
ReactiveList.prototype.fetch = function(noneReactive) { ...
reactive-list.js:282
-