3.8 KiB
#Spinal Queue Spec
This specification declares the interface for the "spinal" queue in PowerQueue.
We allready have two implementations the MicroQueue and ReactiveList
#SpinalQueue Provides a simple reactive list interface
new SpinalQueue(lifo) Anywhere
Arguments
- lifo {boolean}
Set the order of the queue default is
fifo
Example:
var list = new SpinalQueue();
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();
};
SpinalQueue.length() Anywhere
This method length is defined in SpinalQueue
Returns {number} (is reactive) Length of the reactive list
SpinalQueue.reset() Anywhere
This method reset is defined in SpinalQueue
SpinalQueue.update(key, value) Anywhere
This method update is defined in SpinalQueue
Arguments
- key {string|number}
Key to update - value {any}
Update with this value
Note: Method is currently not used by
PowerQueue
SpinalQueue.insert(key, value) Anywhere
This method insert is defined in SpinalQueue
Arguments
- key {string|number}
Key to insert - value {any}
Insert item with this value
SpinalQueue.remove(key) Anywhere
This method remove is defined in SpinalQueue
Arguments
- key {string|number}
Key to remove
SpinalQueue.getLastItem() Anywhere
This method getLastItem is defined in SpinalQueue
Returns {any} Pops last item from the list - removes the item from the list
Note: Method is currently not used by
PowerQueue
SpinalQueue.getFirstItem() Anywhere
This method getFirstItem is defined in SpinalQueue
Returns {any} Pops first item from the list - removes the item from the list
SpinalQueue.forEach(f, [noneReactive], [reverse]) Anywhere
This method forEach is defined in SpinalQueue
Arguments
- f {function}
Callbackfunciton(value, key) - noneReactive {boolean} (Optional = false) Set true if want to disable reactivity
SpinalQueue.forEachReverse(f, [noneReactive]) Anywhere
This method forEachReverse is defined in SpinalQueue
Arguments
- f {function}
Callbackfunciton(value, key) - noneReactive {boolean} (Optional = false) Set true if want to disable reactivity
SpinalQueue.fetch([noneReactive]) Anywhere
This method fetch is defined in SpinalQueue
Arguments
- noneReactive {boolean} (Optional = false) Set true if want to disable reactivity
Returns {array} (is reactive) List of items