@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Interface ITreeDatasource<T>

    Core datasource contract for tree-view.

    Implementations provide the root nodes and child resolution, following the same philosophy as IDatasource<T> for flat data but adapted for hierarchical data.

    interface ITreeDatasource<T = unknown> {
        getChildren(node: TreeNode<T>): TreeNode<T>[] | Promise<TreeNode<T>[]>;
        getRootNodes(): TreeNode<T>[] | Promise<TreeNode<T>[]>;
        hasChildren(node: TreeNode<T>): boolean;
    }

    Type Parameters

    • T = unknown

      The data payload type.

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Returns the children of the given node.

      The default implementation reads node.children. Override this method to support lazy-loading children from a remote source.

      Parameters

      • node: TreeNode<T>

        The parent node whose children are requested.

      Returns TreeNode<T>[] | Promise<TreeNode<T>[]>

    • Returns the root-level nodes of the tree.

      May return synchronously or as a Promise for lazy-loaded trees.

      Returns TreeNode<T>[] | Promise<TreeNode<T>[]>

    • Returns true if the node has children (or might have children that can be lazy-loaded).

      The default implementation checks node.children?.length > 0.

      Parameters

      Returns boolean