Loading libs/data-source/directive/src/lib/data-source.directive.ts +18 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ export class DataSourceDirective<Data = any> public connection$!: Observable<Data>; @Input('rxapDataSourceTrackBy') public trackBy?: (data: Data) => any; /** * @deprecated removed * @protected Loading Loading @@ -113,18 +116,32 @@ export class DataSourceDirective<Data = any> } public embedTemplate(response: any) { const context = { $implicit: response, connection$: this.connection$ }; if (this.embeddedViewRef && !this.hasChanged(this.embeddedViewRef.context.$implicit, response)) { this.embeddedViewRef.context = context; } else { this.embeddedViewRef?.destroy(); this.embeddedViewRef = this.viewContainerRef.createEmbeddedView( this.template, { $implicit: response, connection$: this.connection$, connection$: this.connection$ } ); } this.embedded.emit(response); this.cdr.detectChanges(); } private hasChanged(last: Data, current: Data): boolean { const lastKey = this.trackBy ? this.trackBy(last) : last; const currentKey = this.trackBy ? this.trackBy(current) : current; return lastKey !== currentKey; } public ngOnDestroy(): void { this.dataSource?.disconnect(this.viewer); this.subscription.unsubscribe(); Loading Loading
libs/data-source/directive/src/lib/data-source.directive.ts +18 −1 Original line number Diff line number Diff line Loading @@ -68,6 +68,9 @@ export class DataSourceDirective<Data = any> public connection$!: Observable<Data>; @Input('rxapDataSourceTrackBy') public trackBy?: (data: Data) => any; /** * @deprecated removed * @protected Loading Loading @@ -113,18 +116,32 @@ export class DataSourceDirective<Data = any> } public embedTemplate(response: any) { const context = { $implicit: response, connection$: this.connection$ }; if (this.embeddedViewRef && !this.hasChanged(this.embeddedViewRef.context.$implicit, response)) { this.embeddedViewRef.context = context; } else { this.embeddedViewRef?.destroy(); this.embeddedViewRef = this.viewContainerRef.createEmbeddedView( this.template, { $implicit: response, connection$: this.connection$, connection$: this.connection$ } ); } this.embedded.emit(response); this.cdr.detectChanges(); } private hasChanged(last: Data, current: Data): boolean { const lastKey = this.trackBy ? this.trackBy(last) : last; const currentKey = this.trackBy ? this.trackBy(current) : current; return lastKey !== currentKey; } public ngOnDestroy(): void { this.dataSource?.disconnect(this.viewer); this.subscription.unsubscribe(); Loading