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

    Interface IReorderableDatasource<T>

    A datasource that supports reordering items by index.

    Implement this interface when the datasource can move an item from one position to another. UI components use the isReorderableDatasource type guard to detect this capability before calling moveItem.

    interface IReorderableDatasource<T = unknown> {
        getNumberOfItems(): number | Promise<number>;
        getObjectAtRowIndex(rowIndex: number): RowResult<T>;
        moveItem(fromIndex: number, toIndex: number): void;
    }

    Type Parameters

    • T = unknown

      The row object type.

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Returns the total number of items, synchronously or asynchronously.

      Returns number | Promise<number>

    • Returns the row object at the given index.

      Parameters

      • rowIndex: number

        Zero-based index of the row to retrieve.

      Returns RowResult<T>

      The row value, or a Promise that resolves to it.

    • Moves the item at fromIndex to toIndex, shifting other items to accommodate.

      After this call, subsequent calls to getObjectAtRowIndex() and getNumberOfItems() must reflect the new order.

      Parameters

      • fromIndex: number

        The current zero-based index of the item to move.

      • toIndex: number

        The desired zero-based index for the item.

      Returns void