Interface ExtApi<EN>

A generic local changes API for a JSON CRDT node.

interface ExtApi<EN> {
    api: ModelApi<any>;
    node: EN;
    get events(): NodeEvents<N>;
    arr(path?): ArrApi<ArrNode<any>>;
    asArr(): ArrApi<ArrNode<any>>;
    asBin(): BinApi;
    asCon(): ConApi<ConNode<any>>;
    asExt(): undefined | ExtApi<any> | JsonNodeApi<VecNodeExtensionData<EN>>;
    asExt<EN, EApi>(ext): EApi;
    asObj(): ObjApi<ObjNode<any>>;
    asStr(): StrApi;
    asVal(): ValApi<ValNode<any>>;
    asVec(): VecApi<VecNode<any>>;
    bin(path?): BinApi;
    con(path?): ConApi<ConNode<any>>;
    find(path?): JsonNode<unknown>;
    in(path?): ValApi<ValNode<any>>;
    obj(path?): ObjApi<ObjNode<any>>;
    proxy(): ProxyNode<EN>;
    str(path?): StrApi;
    toString(tab?): string;
    val(path?): ValApi<ValNode<any>>;
    vec(path?): VecApi<VecNode<any>>;
    view(): JsonNodeView<EN>;
}

Type Parameters

  • EN extends ExtNode<any>

Hierarchy (view full)

Properties

api: ModelApi<any>
node: EN

Accessors

  • get events(): NodeEvents<N>
  • Event target for listening to node changes. You can subscribe to "view" events, which are triggered every time the node's view changes.

    node.events.on('view', () => {
    // do something...
    });

    Returns NodeEvents<N>

Methods

  • Returns the API object of the extension if the node is an extension node. When the ext parameter is provided, it checks if the node is an instance of the given extension and returns the object's TypeScript type. Otherwise, it returns the API object of the extension, but without any type checking.

    Returns undefined | ExtApi<any> | JsonNodeApi<VecNodeExtensionData<EN>>

    API of the extension

  • Type Parameters

    • EN extends ExtNode<any, any>
    • EApi extends ExtApi<EN>

    Parameters

    • ext: Extension<any, any, EN, EApi, any, any>

    Returns EApi