new YArray()
- Implements:
- Iterable.<T>
Extends
- AbstractType.<YArrayEvent.<T>>
Members
-
_prelimContent :Array.<any>
-
-
_searchMarker :Array.<ArraySearchMarker>
-
Methods
-
_callObserver(transaction, parentSubs)
-
Creates YArrayEvent and calls observers.
Parameters:
Name Type Description transactionTransaction parentSubsSet.<(null|string)> Keys changed on this type.
nullif list was modified. -
_integrate(y, item)
-
Integrate this type into the Yjs instance.
- Save this struct in the os
- This type is sent to other client
- Observer functions are fired
Parameters:
Name Type Description yDoc The Yjs instance
itemItem -
_write(encoder)
-
Parameters:
Name Type Description encoderAbstractUpdateEncoder -
delete(index, length)
-
Deletes elements starting from an index.
Parameters:
Name Type Default Description indexnumber Index at which to start deleting elements
lengthnumber 1 The number of elements to remove. Defaults to 1.
-
forEach(f)
-
Executes a provided function on once on overy element of this YArray.
Parameters:
Name Type Description ffunction A function to execute on every element of this YArray.
-
get(index) → {T}
-
Returns the i-th element from a YArray.
Parameters:
Name Type Description indexnumber The index of the element to return from the YArray
Returns:
T -
insert(index, content)
-
Inserts new content at an index.
Important: This function expects an array of content. Not just a content object. The reason for this "weirdness" is that inserting several elements is very efficient when it is done as a single operation.
Parameters:
Name Type Description indexnumber The index to insert content at.
contentArray.<T> The array of content
Example
// Insert character 'a' at position 0 yarray.insert(0, ['a']) // Insert numbers 1, 2 at position 1 yarray.insert(1, [1, 2]) -
map(f) → {Array.<M>}
-
Returns an Array with the result of calling a provided function on every element of this YArray.
Parameters:
Name Type Description ffunction Function that produces an element of the new Array
Returns:
Array.<M> -A new array with each element being the result of the callback function
-
push(content)
-
Appends content to this YArray.
Parameters:
Name Type Description contentArray.<T> Array of content to append.
-
Symbol.iterator() → {IterableIterator.<T>}
-
Returns:
IterableIterator.<T> -
toArray() → {Array.<T>}
-
Transforms this YArray to a JavaScript Array.
Returns:
Array.<T> -
toJSON() → {Array.<any>}
-
Transforms this Shared Type to a JSON object.
Returns:
Array.<any> -
unshift(content)
-
Preppends content to this YArray.
Parameters:
Name Type Description contentArray.<T> Array of content to preppend.