@@ -34,6 +34,7 @@ import { Promise } from '@rx-angular/cdk/zone-less/browser';
34
34
import {
35
35
combineLatest ,
36
36
concat ,
37
+ ConnectableObservable ,
37
38
isObservable ,
38
39
MonoTypeOperatorFunction ,
39
40
NEVER ,
@@ -55,6 +56,8 @@ import {
55
56
tap ,
56
57
} from 'rxjs/operators' ;
57
58
import {
59
+ CollectionViewer ,
60
+ DataSource ,
58
61
ListRange ,
59
62
RxVirtualForViewContext ,
60
63
RxVirtualScrollStrategy ,
@@ -241,6 +244,7 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
241
244
potentialSignalOrObservable :
242
245
| Observable < ( U & NgIterable < T > ) | undefined | null >
243
246
| Signal < ( U & NgIterable < T > ) | undefined | null >
247
+ | DataSource < T >
244
248
| ( U & NgIterable < T > )
245
249
| null
246
250
| undefined ,
@@ -251,6 +255,21 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
251
255
this . observables$ . next (
252
256
toObservable ( potentialSignalOrObservable , { injector : this . injector } ) ,
253
257
) ;
258
+ } else if ( this . isDataSource ( potentialSignalOrObservable ) ) {
259
+ this . staticValue = undefined ;
260
+ this . renderStatic = false ;
261
+
262
+ const collectionViewer : CollectionViewer = {
263
+ viewChange : this . scrollStrategy . renderedRange$ ,
264
+ } ;
265
+
266
+ this . observables$ . next (
267
+ potentialSignalOrObservable . connect ( collectionViewer ) ,
268
+ ) ;
269
+
270
+ this . _destroy$ . pipe ( take ( 1 ) ) . subscribe ( ( ) => {
271
+ potentialSignalOrObservable . disconnect ( collectionViewer ) ;
272
+ } ) ;
254
273
} else if ( ! isObservable ( potentialSignalOrObservable ) ) {
255
274
this . staticValue = potentialSignalOrObservable ;
256
275
this . renderStatic = true ;
@@ -261,6 +280,24 @@ export class RxVirtualFor<T, U extends NgIterable<T> = NgIterable<T>>
261
280
}
262
281
}
263
282
283
+ /** @internal */
284
+ private isDataSource (
285
+ value :
286
+ | ( U & NgIterable < T > )
287
+ | Observable < U & NgIterable < T > >
288
+ | DataSource < T >
289
+ | null
290
+ | undefined ,
291
+ ) : value is DataSource < T > {
292
+ return (
293
+ value !== null &&
294
+ value !== undefined &&
295
+ 'connect' in value &&
296
+ typeof value . connect === 'function' &&
297
+ ! ( value instanceof ConnectableObservable )
298
+ ) ;
299
+ }
300
+
264
301
/**
265
302
* @internal
266
303
* A reference to the template that is created for each item in the iterable.
0 commit comments