    import Type from 'yjs/src/Struct/Type.js'

public class | source

# Type

#### Extends:

Item → Type

#### Direct Subclass:

YArray, YMap

#### Indirect Subclass:

YText, YXmlFragment, YXmlHook, YXmlText

Abstract Yjs Type class

## Constructor Summary

Public Constructor
public | constructor () |

## Method Summary

Public Methods
public | getPathTo (type: YType): Array<string> Compute the path from this type to the specified target. |
public | observe (f: Function) Observe all events that are created on this type. |
public | observeDeep (f: Function) Observe all events that are created by this type and its children. |
public | unobserve (f: Function) Unregister an observer function. |
public | unobserveDeep (f: Function) 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:

Name | Type | Attribute | Description
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:

Name | Type | Attribute | Description
f | Function |  | Observer function

### public observeDeep(f: Function) source

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

#### Params:

Name | Type | Attribute | Description
f | Function |  | Observer function

### public unobserve(f: Function) source

Unregister an observer function.

#### Params:

Name | Type | Attribute | Description
f | Function |  | Observer function

### public unobserveDeep(f: Function) source

Unregister an observer function.

#### Params:

Name | Type | Attribute | Description
f | Function |  | Observer function