Skip to content

Commit

Permalink
feat(4ps): change to use signal
Browse files Browse the repository at this point in the history
  • Loading branch information
develite98 committed Jan 2, 2024
1 parent 4021024 commit fb494d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
[components]="components"
[context]="context"
[defaultColDef]="defaultColDef"
[rowData]="rowData$ | async"
[rowData]="data()"
[rowDragManaged]="true"
[rowSelection]="'multiple'"
[suppressMoveWhenRowDragging]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Component,
OnInit,
inject,
signal,
} from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
Expand Down Expand Up @@ -39,8 +40,8 @@ import {
Subject,
debounceTime,
distinctUntilChanged,
filter,
forkJoin,
map,
take,
takeUntil,
tap,
Expand Down Expand Up @@ -152,14 +153,19 @@ export class DatabaseDataComponent
public displayColumns: string[] = [];
public displayColumns$ = new Subject<string[]>();
public gridApi!: GridApi<MixDynamicData>;
public data = signal<MixDynamicData[]>([]);

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) =>
<ColDef>{
colId: x.systemName,
field: x.systemName,
Expand All @@ -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$))
Expand Down

1 comment on commit fb494d4

@vercel
Copy link

@vercel vercel bot commented on fb494d4 Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.