json-joy
    Preparing search index...

    Class ValApi<N>

    Local changes API for the val JSON CRDT node ValNode.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    api: ModelApi<any>
    node: N

    Accessors

    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<N>>

      API of the extension

    • 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.

      Type Parameters

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

      Parameters

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

        Extension of the node

      Returns EApi

      API of the extension

    • Find a child node at the given path starting from this node and wrap it in a local changes API.

      Type Parameters

      • B extends boolean = false

      Parameters

      • Optionalpath: ApiPath

        Path to the child node to find.

      • noThrow: B = ...

      Returns B extends true
          ? undefined
          | NodeApi<JsonNode<unknown>>
          : NodeApi<JsonNode<unknown>>

      Local changes API for the child node at the given path.

    • Attaches a listener which executes on every change that is applied to this node's children. Hence, this listener will trigger only for container nodes - nodes that can have child nodes, such as "obj", "arr", "vec", and "val" nodes. It will not execute on changes made directly to this node.

      If you want to listen to changes on this node as well as its children, use onSubtreeChange() method. If you want to listen to changes on this node only, use onSelfChange() method.

      Parameters

      • listener: (event: ChangeEvent) => void

        Callback called on every change that is applied to children of this node.

      Returns FanOutUnsubscribe

      Returns an unsubscribe function to stop listening to the events.

      • onSelfChange()
      • onSubtreeChange()
    • Attaches a listener which executes on every change that is applied to this node or any of its child nodes (recursively). The kind parameter allows you to specify the type of changes to listen to: "self" for changes directly on this node, "child" for changes on child nodes, and "subtree" for both.

      Parameters

      • kind: "child" | "self" | "subtree"

        The type of changes to listen to: "self", "child", or "subtree".

      • listener: (event: ChangeEvent) => void

        Callback called on every change that matches the specified type.

      Returns FanOutUnsubscribe

      Returns an unsubscribe function to stop listening to the events.

    • Attaches a listener which executes on every change that is executed directly on this node. For example, if this is a "str" string node and you insert or delete text, the listener will be executed. Or if this is an "obj" object node and keys of this object are changed, this listener will be executed.

      It does not trigger when child nodes are edit, to include those changes, use onSubtreeChange() or onChildChange() methods.

      Parameters

      • listener: (event: ChangeEvent) => void

        Callback called on every change that is executed directly on this node.

      Returns FanOutUnsubscribe

      Returns an unsubscribe function to stop listening to the events.

      • onChildChange()
      • onSubtreeChange()
    • Attaches a listener which executes on every change that is applied to this node or any of its child nodes (recursively). This is equivalent to combining both onSelfChange() and onChildChange() methods.

      Parameters

      • listener: (event: ChangeEvent) => void

        Callback called on every change that is applied to this node or any of its child nodes.

      Returns FanOutUnsubscribe

      Returns an unsubscribe function to stop listening to the events.

      • onSelfChange()
      • onChildChange()