Constructs a new CollectionViewDataSource with initial rows.
The initial rows to load.
Private_The collection view that this data source is associated with.
PrivateappInjected style registry for resolving row styles.
PrivatedefaultDefault style key for error rows.
Unique ID for this data source instance.
PrivateloadingNumber of loading items to add to a dynamic row.
PrivateonList of callbacks to notify when the data source changes.
PrivatependingList of pending change notifications to be applied.
PrivaterowsArray to maintain the rows directly.
PrivaterowsMap of rows by ID for efficient access.
PrivaterowMap to track the version of each row.
PrivateviewInjected view manager for error reporting.
Adds loaded items to a row by row ID.
The ID of the row.
The items to add.
Whether to apply the change immediately.
PrivateaddAppends items to a row by row ID.
The ID of the row.
The items to append.
Whether to apply the change immediately.
Appends rows to the data source at the specified index.
The rows to append.
Optionalindex: numberThe index to insert at (optional).
Whether to apply the change immediately.
PrivateapplyApplies the default error style to a row if style resolution fails.
The row to apply the error style to.
Applies all pending updates and notifies registered callbacks.
Changes the enabled state of a row.
The ID of the row.
Whether the row should be enabled.
Whether to apply the change immediately.
Changes the visibility of a row.
The ID of the row.
Whether the row should be visible.
Whether to apply the change immediately.
Clears all rows from the data source. Changes are applied synchronously.
Gets a row by its index.
The index of the row.
The row at the specified index.
Gets a row by its unique ID.
The ID of the row.
The row with the specified ID, or undefined if not found.
Gets all rows in the data source.
The array of rows.
PrivateincrementIncrements the version number for a row.
The ID of the row.
PrivateloadLoads initial data into the data source.
The rows to load.
OptionalrestoreIndices: [number, number]Optional [rowIndex, itemIndex] to restore scroll/focus (used by replaceAllRows).
Marks a row as invalid, triggering a change event.
The ID of the row.
Whether to apply the change immediately.
Moves a row to a new index in the data source.
The ID of the row to move.
The new index to move the row to.
Whether to apply the change immediately.
Registers a callback to be called when the data source changes.
The callback function.
Removes items from a row by row ID and item index range.
The ID of the row.
The start index of items to remove.
The end index of items to remove.
Whether to apply the change immediately.
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.
The exact callback reference passed to onDataSourceChanged.
Removes a row from the data source by ID.
The ID of the row to remove.
Whether to apply the change immediately.
Replaces all rows with new data, preserving focus position when valid. Stores current focused row and item index, clears and sets new data, then jumps to the stored indices (or 0,0 if invalid). Changes are applied synchronously.
The new rows to set.
PrivatereportReports an error to the view manager.
The error message.
The type of error.
PrivateresolveSets the collection view that this data source is associated with.
The collection view to set.
Sets an error object for the data source (not implemented).
The debug error object.
Sets the initial data for the data source, clearing any existing rows. Changes are applied synchronously.
The rows to set as initial data.
PrivatetriggerTriggers a change event and optionally applies updates immediately.
The change event to trigger.
Whether to apply the change immediately.
Updates an item in a row by row ID and item index.
The ID of the row.
The index of the item to update.
The new item to set.
Whether to apply the change immediately.
Updates the layout of a row by row ID.
The row to update the layout for.
The new data for the row.
Whether to apply the change immediately.
CollectionViewDataSource manages the data for a collection view. Handles row and item management, change tracking, and notifies listeners of data changes.