@@ -98,42 +98,47 @@ export function injectTable<
9898 const injector = inject ( Injector )
9999 const ngZone = inject ( NgZone )
100100 const options = computed ( ( ) => _options ( ) )
101+ const coreReactivityFeature = angularReactivity ( injector )
102+
103+ let table : Table < TFeatures , TData >
104+ injector . get ( DestroyRef ) . onDestroy ( ( ) => {
105+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
106+ if ( table ) {
107+ table . _reactivity . unmount ?.( )
108+ }
109+ } )
110+
111+ let previousOptions : TableOptions < TFeatures , TData >
112+ effect (
113+ ( ) => {
114+ const currentOptions = options ( )
115+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
116+ if ( ! table ) {
117+ return
118+ }
119+ if ( previousOptions === currentOptions ) {
120+ return
121+ }
122+ untracked ( ( ) =>
123+ table . setOptions ( ( previous ) => ( {
124+ ...previous ,
125+ ...currentOptions ,
126+ } ) ) ,
127+ )
128+ previousOptions = currentOptions
129+ } ,
130+ { injector, debugName : 'tableOptionsUpdate' } ,
131+ )
101132
102133 return ngZone . runOutsideAngular ( ( ) =>
103134 lazyInit ( ( ) => {
104- // Explicit type arguments skip generic inference from the spread object
105- // (a type-check hot spot); the spread only adds the angular reactivity
106- // binding to `features`.
107- const table = constructTable < TFeatures , TData > ( {
135+ table = constructTable < TFeatures , TData > ( {
108136 ...options ( ) ,
109137 features : {
110- coreReactivityFeature : angularReactivity ( injector ) ,
138+ coreReactivityFeature,
111139 ...options ( ) . features ,
112140 } ,
113141 } )
114-
115- injector . get ( DestroyRef ) . onDestroy ( ( ) => {
116- table . _reactivity . unmount ?.( )
117- } )
118-
119- let previousOptions = options ( )
120- effect (
121- ( ) => {
122- const currentOptions = options ( )
123- if ( previousOptions === currentOptions ) {
124- return
125- }
126- untracked ( ( ) =>
127- table . setOptions ( ( previous ) => ( {
128- ...previous ,
129- ...currentOptions ,
130- } ) ) ,
131- )
132- previousOptions = currentOptions
133- } ,
134- { injector, debugName : 'tableOptionsUpdate' } ,
135- )
136-
137142 return table
138143 } ) ,
139144 )
0 commit comments