Hosanna UI API v1.30.2-next
    Preparing search index...

    CollectionViewDataSource manages the data for a collection view. Handles row and item management, change tracking, and notifies listeners of data changes.

    Index

    Constructors

    Properties

    _collectionView: undefined | CollectionViewView = undefined

    The collection view that this data source is associated with.

    appConfig: AppConfig.AppConfig

    Injected style registry for resolving row styles.

    defaultErrorRowStyle: string = 'rows.regularError'

    Default style key for error rows.

    id: string = ...

    Unique ID for this data source instance.

    loadingItemsCount: number = 6

    Number of loading items to add to a dynamic row.

    onChangeCallbacks: ((change: IDataSourceChange[]) => void)[] = []

    List of callbacks to notify when the data source changes.

    pendingChangesNotifications: IDataSourceChange[] = []

    List of pending change notifications to be applied.

    Array to maintain the rows directly.

    rowsById: Map<
        string,
        ICollectionViewDataSourceRow<any, ICollectionViewDataSourceItem>,
    >

    Map of rows by ID for efficient access.

    rowVersions: Map<string, number> = ...

    Map to track the version of each row.

    Injected view manager for error reporting.

    Methods

    • Adds loaded items to a row by row ID.

      Parameters

      • rowId: string

        The ID of the row.

      • items: IIdentifiable[]

        The items to add.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Appends items to a row by row ID.

      Parameters

      • rowId: string

        The ID of the row.

      • items: any[]

        The items to append.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Applies all pending updates and notifies registered callbacks.

      Returns void

    • Changes the enabled state of a row.

      Parameters

      • rowId: string

        The ID of the row.

      • isEnabled: boolean

        Whether the row should be enabled.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Changes the visibility of a row.

      Parameters

      • rowId: string

        The ID of the row.

      • isHidden: boolean

        Whether the row should be visible.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Clears all rows from the data source. Changes are applied synchronously.

      Returns void

    • Increments the version number for a row.

      Parameters

      • rowId: string

        The ID of the row.

      Returns void

    • Parameters

      • rowId: string
      • items: IIdentifiable[]
      • index: number | "end" | "end-1" | "end-2" | "end - 1" | "end - 2"
      • applyNow: boolean = false

      Returns void

    • Marks a row as invalid, triggering a change event.

      Parameters

      • rowId: string

        The ID of the row.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Moves a row to a new index in the data source.

      Parameters

      • rowId: string

        The ID of the row to move.

      • newIndex: number

        The new index to move the row to.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Registers a callback to be called when the data source changes.

      Parameters

      Returns void

    • Removes items from a row by row ID and item index range.

      Parameters

      • rowId: string

        The ID of the row.

      • startIndex: number

        The start index of items to remove.

      • endIndex: number

        The end index of items to remove.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Unregisters a previously registered change callback.

      A data source can outlive the CollectionView(s) bound to it (e.g. a screen keeps a single data source while its pooled CollectionView is reused). Without removal, each rebind leaves a stale callback in onChangeCallbacks, so one applyUpdates() notifies the same view multiple times — re-queuing identical changes and rendering duplicate rows. Views must call this when they detach.

      Parameters

      Returns void

    • Removes a row from the data source by ID.

      Parameters

      • rowId: string

        The ID of the row to remove.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void

    • Reports an error to the view manager.

      Parameters

      • message: string

        The error message.

      • errorType: DebugErrorType

        The type of error.

      Returns void

    • Parameters

      • index: number | "end" | "end-1" | "end-2" | "end - 1" | "end - 2"
      • length: number

      Returns number

    • Sets the collection view that this data source is associated with.

      Parameters

      Returns void

    • Sets an error object for the data source (not implemented).

      Parameters

      • errorObj: IDebugErrorObject

        The debug error object.

      Returns void

    • Triggers a change event and optionally applies updates immediately.

      Parameters

      • change: IDataSourceChange

        The change event to trigger.

      • applyNow: boolean

        Whether to apply the change immediately.

      Returns void

    • Updates an item in a row by row ID and item index.

      Parameters

      • rowId: string

        The ID of the row.

      • itemIndex: number

        The index of the item to update.

      • newItem: IIdentifiable

        The new item to set.

      • applyNow: boolean = false

        Whether to apply the change immediately.

      Returns void