From fb494d4606511f18863a790b88b24caf706964e0 Mon Sep 17 00:00:00 2001 From: develite98 Date: Tue, 2 Jan 2024 13:17:07 +0700 Subject: [PATCH] feat(4ps): change to use signal --- .../database-data.component.html | 2 +- .../database-data/database-data.component.ts | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libs/mix-share/src/modules/database/database-data/database-data.component.html b/libs/mix-share/src/modules/database/database-data/database-data.component.html index ca2a121e..7f541ec3 100644 --- a/libs/mix-share/src/modules/database/database-data/database-data.component.html +++ b/libs/mix-share/src/modules/database/database-data/database-data.component.html @@ -116,7 +116,7 @@ [components]="components" [context]="context" [defaultColDef]="defaultColDef" - [rowData]="rowData$ | async" + [rowData]="data()" [rowDragManaged]="true" [rowSelection]="'multiple'" [suppressMoveWhenRowDragging]="true" diff --git a/libs/mix-share/src/modules/database/database-data/database-data.component.ts b/libs/mix-share/src/modules/database/database-data/database-data.component.ts index 004187be..cca13122 100644 --- a/libs/mix-share/src/modules/database/database-data/database-data.component.ts +++ b/libs/mix-share/src/modules/database/database-data/database-data.component.ts @@ -4,6 +4,7 @@ import { Component, OnInit, inject, + signal, } from '@angular/core'; import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; @@ -39,8 +40,8 @@ import { Subject, debounceTime, distinctUntilChanged, + filter, forkJoin, - map, take, takeUntil, tap, @@ -152,14 +153,19 @@ export class DatabaseDataComponent public displayColumns: string[] = []; public displayColumns$ = new Subject(); public gridApi!: GridApi; + public data = signal([]); public onGridReady(params: GridReadyEvent) { this.gridApi = params.api; - this.rowData$ = this.store.vm$.pipe( - tap((s) => { + this.store.vm$ + .pipe( + filter((s) => !!s.db), + takeUntil(this.destroy$) + ) + .subscribe((s) => { if (s.db) { this.allColumnDefs = s.db.columns.map( - (x, i) => + (x) => { colId: x.systemName, field: x.systemName, @@ -178,13 +184,10 @@ export class DatabaseDataComponent ...this.allColumnDefs, this.actionColumnDef, ]; + + this.data.set(s.data); } - }), - map((s) => { - return s.data; - }), - takeUntil(this.destroy$) - ); + }); this.displayColumns$ .pipe(distinctUntilChanged(), debounceTime(0), takeUntil(this.destroy$))