splice-stream
Stream changes to an array
Data protocol
[[/* Array.prototype.splice arguments */], timestamp, sourceIdentifier]
A splice-stream emits an array, where the first value is an array of parameters compatible with Array.prototype.slice
. This represents the delta in change on an array.
The second value is a time stamp which can be used for clever synchronization.
The third value is a source identifier. It's used to identify who created this splice
Example
var SpliceStream =var stream1 =stream2 =var list1 = stream1list2 = stream2list1list2stream2list2 // [LIST1] bar 0console // lengths 1 1list1 // [LIST2] bar
Movable List
Sometimes you don't want to add / remove items but move them inside a single list. Use a MovableList to represent moves of items
var MovableList = MovableListvar list1 =// When an item moves around in the listlist1// Normal list eventslist1list1list1// Wait a tick to register the addsprocess
Installation
npm install splice-stream
Compatible modules
Compatible minus one issue
Contributors
- Raynos