$ cnpm install y-array2
This plugins provides a shareable Array type. You can insert and delete objects in y-array. The objects must either be a custom type,
or fulfill the following property: v equals JSON.parse(JSON.stringify(v))
(according to your definition of equality)
Install this with bower or npm.
bower install y-array --save
npm install y-array --save
array.insert(0, Y.Map)
content equals JSON.parse(JSON.stringify(content))
(according to your notion of equality).insert(..)
observer
is called whenever something on this array changesevent.type
){type: 'insert', index: 0, values: [0, 1, 2], length: 3}
{type: 'delete', index: 0, oldValues: [0, 1, 2], length: 3}
event.path
specifies the path of the change eventIf two users insert something at the same position concurrently, the content that was inserted by the user with the higher user-id will be to the right of the other content. In the OT world we often speak of intention preservation, which is very loosely defined in most cases. This type has the following notion of intention preservation: When a user inserts content c after a set of content C_left, and before a set of content C_right, then C_left will be always to the left of c, and C_right will be always to the right of c. Since content is only marked as deleted (until all conflicts are resolved), this notion of intention preservation is very strong.
Yjs is licensed under the MIT License.
Copyright 2014 - 2017 © taobao.org |