Loading libs/data-source/CHANGELOG +4 −0 Original line number Diff line number Diff line # Changelog ## [0.6.0] ### Changed - (DataSourceDirective): run template creation in zone ## [0.5.2] ### Added - fix viewer is issue Loading libs/data-source/directive/src/lib/data-source.directive.ts +24 −8 Original line number Diff line number Diff line Loading @@ -8,7 +8,9 @@ import { OnDestroy, ChangeDetectorRef, OnChanges, SimpleChanges SimpleChanges, NgZone, EmbeddedViewRef } from '@angular/core'; import { DataSourceLoader, Loading @@ -16,7 +18,10 @@ import { BaseDataSourceViewer } from '@rxap/data-source'; import { Required } from '@rxap/utilities'; import { tap } from 'rxjs/operators'; import { tap, take } from 'rxjs/operators'; import { Observable, Subscription Loading Loading @@ -47,12 +52,15 @@ export class DataSourceDirective<Data = any> implements OnDestroy, OnChanges { protected readonly subscription = new Subscription(); protected embeddedViewRef?: EmbeddedViewRef<DataSourceTemplate<Data>>; constructor( private readonly dataSourceLoader: DataSourceLoader, private readonly template: TemplateRef<DataSourceTemplate<Data>>, private readonly viewContainerRef: ViewContainerRef, private readonly injector: Injector, private readonly cdr: ChangeDetectorRef private readonly cdr: ChangeDetectorRef, private readonly zone: NgZone ) { this.viewer = this; } Loading Loading @@ -81,16 +89,24 @@ export class DataSourceDirective<Data = any> implements OnDestroy, OnChanges { if (this.dataSource) { this.connection$ = this.dataSource .connect(this.viewer); this.subscription.add(this.connection$.pipe( tap(response => this.embedTemplate(response)) ) this.zone.onStable.pipe( take(1), tap(() => { this.zone.run(() => { this.subscription.add(this .connection$ .pipe(tap(response => this.embedTemplate(response))) .subscribe()); }); }) ).subscribe(); } } public embedTemplate(response: any) { this.viewContainerRef.clear(); this.viewContainerRef.createEmbeddedView(this.template, { this.embeddedViewRef?.destroy(); this.embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.template, { $implicit: response, connection$: this.connection$ }); Loading libs/data-source/package.json +1 −1 Original line number Diff line number Diff line { "name": "@rxap/data-source", "version": "0.5.2", "version": "0.6.0", "private": false, "author": "Merzough Münker", "homepage": "https://gitlab.com/rxap/packages", Loading Loading
libs/data-source/CHANGELOG +4 −0 Original line number Diff line number Diff line # Changelog ## [0.6.0] ### Changed - (DataSourceDirective): run template creation in zone ## [0.5.2] ### Added - fix viewer is issue Loading
libs/data-source/directive/src/lib/data-source.directive.ts +24 −8 Original line number Diff line number Diff line Loading @@ -8,7 +8,9 @@ import { OnDestroy, ChangeDetectorRef, OnChanges, SimpleChanges SimpleChanges, NgZone, EmbeddedViewRef } from '@angular/core'; import { DataSourceLoader, Loading @@ -16,7 +18,10 @@ import { BaseDataSourceViewer } from '@rxap/data-source'; import { Required } from '@rxap/utilities'; import { tap } from 'rxjs/operators'; import { tap, take } from 'rxjs/operators'; import { Observable, Subscription Loading Loading @@ -47,12 +52,15 @@ export class DataSourceDirective<Data = any> implements OnDestroy, OnChanges { protected readonly subscription = new Subscription(); protected embeddedViewRef?: EmbeddedViewRef<DataSourceTemplate<Data>>; constructor( private readonly dataSourceLoader: DataSourceLoader, private readonly template: TemplateRef<DataSourceTemplate<Data>>, private readonly viewContainerRef: ViewContainerRef, private readonly injector: Injector, private readonly cdr: ChangeDetectorRef private readonly cdr: ChangeDetectorRef, private readonly zone: NgZone ) { this.viewer = this; } Loading Loading @@ -81,16 +89,24 @@ export class DataSourceDirective<Data = any> implements OnDestroy, OnChanges { if (this.dataSource) { this.connection$ = this.dataSource .connect(this.viewer); this.subscription.add(this.connection$.pipe( tap(response => this.embedTemplate(response)) ) this.zone.onStable.pipe( take(1), tap(() => { this.zone.run(() => { this.subscription.add(this .connection$ .pipe(tap(response => this.embedTemplate(response))) .subscribe()); }); }) ).subscribe(); } } public embedTemplate(response: any) { this.viewContainerRef.clear(); this.viewContainerRef.createEmbeddedView(this.template, { this.embeddedViewRef?.destroy(); this.embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.template, { $implicit: response, connection$: this.connection$ }); Loading
libs/data-source/package.json +1 −1 Original line number Diff line number Diff line { "name": "@rxap/data-source", "version": "0.5.2", "version": "0.6.0", "private": false, "author": "Merzough Münker", "homepage": "https://gitlab.com/rxap/packages", Loading