MCPcopy Index your code
hub / github.com/TanStack/table / proxifyTable

Function proxifyTable

packages/angular-table/src/proxy.ts:6–58  ·  view source on GitHub ↗
(
  tableSignal: Signal<Table<T>>
)

Source from the content-addressed store, hash-verified

4type TableSignal<T> = Table<T> & Signal<Table<T>>
5
6export function proxifyTable<T>(
7 tableSignal: Signal<Table<T>>
8): Table<T> & Signal<Table<T>> {
9 const internalState = tableSignal as TableSignal<T>
10
11 return new Proxy(internalState, {
12 apply() {
13 return tableSignal()
14 },
15 get(target, property: keyof Table<T>): any {
16 if (target[property]) {
17 return target[property]
18 }
19 const table = untracked(tableSignal)
20 /**
21 * Attempt to convert all accessors into computed ones,
22 * excluding handlers as they do not retain any reactive value
23 */
24 if (
25 property.startsWith('get') &&
26 !property.endsWith('Handler')
27 // e.g. getCoreRowModel, getSelectedRowModel etc.
28 // We need that after a signal change even `rowModel` may mark the view as dirty.
29 // This allows to always get the latest `getContext` value while using flexRender
30 // && !property.endsWith('Model')
31 ) {
32 const maybeFn = table[property] as Function | never
33 if (typeof maybeFn === 'function') {
34 Object.defineProperty(target, property, {
35 value: toComputed(tableSignal, maybeFn),
36 configurable: true,
37 enumerable: true,
38 })
39 return target[property]
40 }
41 }
42 // @ts-expect-error
43 return (target[property] = table[property])
44 },
45 has(_, prop: keyof Table<T>) {
46 return !!untracked(tableSignal)[prop]
47 },
48 ownKeys() {
49 return Reflect.ownKeys(untracked(tableSignal))
50 },
51 getOwnPropertyDescriptor() {
52 return {
53 enumerable: true,
54 configurable: true,
55 }
56 },
57 })
58}
59
60/**
61 * Here we'll handle all type of accessors:

Callers 1

createAngularTableFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…