Home Reference Source
import Type from 'yjs/src/Struct/Type.js'
public class | source

Type

Extends:

Item → Type

Direct Subclass:

YArray, YMap

Abstract Yjs Type class

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

getPathTo(type: YType): Array<string>

Compute the path from this type to the specified target.

public

Observe all events that are created on this type.

public

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

public

Unregister an observer function.

public

Unregister an observer function.

Public Constructors

public constructor() source

Override:

Item#constructor

Public Methods

public getPathTo(type: YType): Array<string> source

Compute the path from this type to the specified target.

Params:

NameTypeAttributeDescription
type YType

Type target

Return:

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])

public observe(f: Function) source

Observe all events that are created on this type.

Params:

NameTypeAttributeDescription
f Function

Observer function

public observeDeep(f: Function) source

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

Params:

NameTypeAttributeDescription
f Function

Observer function

public unobserve(f: Function) source

Unregister an observer function.

Params:

NameTypeAttributeDescription
f Function

Observer function

public unobserveDeep(f: Function) source

Unregister an observer function.

Params:

NameTypeAttributeDescription
f Function

Observer function