-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperson-entity-store.service.ts
44 lines (37 loc) · 1.08 KB
/
person-entity-store.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Injectable, Signal, computed } from '@angular/core';
import { patchState } from '@ngrx/signals';
import {
AbstractEntityStoreService,
AdditionalStoreHooks,
DateAsString,
dateToString,
} from '@angular-monorepo/shared/util-common';
import { PersonInterface as EntityInterface }
from '@angular-monorepo/persons-management/domain';
import { personsUrl as entitiesUrl } from './urls';
type MoreData = {
currentDate: DateAsString;
};
@Injectable({
providedIn: 'root',
})
export class PersonEntityStoreService extends AbstractEntityStoreService<EntityInterface> {
protected override getDevToolsScope(): string {
return 'Persons';
}
protected override getEntitiesUrl(): string {
return entitiesUrl;
}
protected override getAdditionalHooks(): AdditionalStoreHooks {
return {
sideEffectsOnInit: (store): void => {
patchState(store, {
moreData: { currentDate: dateToString(new Date()) } as MoreData,
});
},
};
}
get currentDate(): Signal<DateAsString> {
return computed(() => this.store.moreData().currentDate);
}
}