structs.Type()

Abstract Yjs Type class

new Type()

Members

_first

The first non-deleted item

Methods

getPathTo(type) → {Array.<string>}

Compute the path from this type to the specified target.

Parameters:
Name Type Description
type Type | Y | any

Type target

Returns:
Array.<string> -

Path to the target

Example
It should be accessible via `this.get(result[0]).get(result[1])..`
const path = type.getPathTo(child)
// assuming `type instanceof YArray`
console.log(path) // might look like => [2, 'key1']
child === type.get(path[0]).get(path[1])

observe(f)

Observe all events that are created on this type.

Parameters:
Name Type Description
f function

Observer function

observeDeep(f)

Observe all events that are created by this type and its children.

Parameters:
Name Type Description
f function

Observer function

abstract toJSON() → {Object|Array|number|string}

Returns:
Object | Array | number | string

unobserve(f)

Unregister an observer function.

Parameters:
Name Type Description
f function

Observer function

unobserveDeep(f)

Unregister an observer function.

Parameters:
Name Type Description
f function

Observer function