Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/table-core/src/core/rows/constructRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const constructRow = <
row.subRows = subRows ?? []

// Initialize instance-specific data (e.g., caches) for features that need it
const features = Object.values(table._features)
for (let i = 0; i < features.length; i++) {
features[i]!.initRowInstanceData?.(row)
const initFns = table._rowInstanceInitFns!
for (let i = 0; i < initFns.length; i++) {
initFns[i]!(row as Row<TFeatures, TData>)
}

return row as Row<TFeatures, TData>
Expand Down
10 changes: 10 additions & 0 deletions packages/table-core/src/core/table/constructTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ export function constructTable<

const featuresList: Array<TableFeature> = Object.values(table._features)

const rowInstanceInitFns: Array<
NonNullable<TableFeature['initRowInstanceData']>
> = []
for (const feature of featuresList) {
if (feature.initRowInstanceData) {
rowInstanceInitFns.push(feature.initRowInstanceData.bind(feature))
}
}
table._rowInstanceInitFns = rowInstanceInitFns
Comment thread
43081j marked this conversation as resolved.

const defaultOptions = featuresList.reduce((obj, feature) => {
return Object.assign(obj, feature.getDefaultTableOptions?.(table))
}, {}) as TableOptions<TFeatures, TData>
Expand Down
5 changes: 5 additions & 0 deletions packages/table-core/src/core/table/coreTablesFeature.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { RowModelFns } from '../../types/RowModelFns'
import type { RowData, Updater } from '../../types/type-utils'
import type {
IsAny,
TableFeature,
TableFeatures,
ValidateFeatureSlots,
} from '../../types/TableFeatures'
Expand Down Expand Up @@ -188,6 +189,10 @@ export interface Table_CoreProperties<
* Prototype cache for Row objects - shared by all rows in this table
*/
_rowPrototype?: object
/**
* Cache of the `initRowInstanceData` functions for features that define one.
*/
_rowInstanceInitFns?: Array<NonNullable<TableFeature['initRowInstanceData']>>
/**
* The readonly derived atoms for each `TableState` slice. Each derives from
* its corresponding `baseAtom` plus, optionally, a per-slice external atom or
Expand Down
Loading