#Spinal Queue Spec
This specification declares the interface for the "spinal" queue in `PowerQueue`.
We allready have two implementations the [MicroQueue](https://github.com/zcfs/Meteor-micro-queue) and [ReactiveList](https://github.com/zcfs/Meteor-reactive-list)
#SpinalQueue
Provides a simple reactive list interface
#### new SpinalQueue(lifo) Anywhere ####
-
__Arguments__
* __lifo__ *{boolean}*
Set the order of the queue default is `fifo`
-
Example:
```js
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}*
Callback `funciton(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}*
Callback `funciton(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
-