|
| 1 | +import { inject, Injectable } from '@angular/core'; |
| 2 | +import { CategoryStore } from '../store/category-store/category-store'; |
| 3 | +import { ManufacturerStore } from '../store/manufacturer-store/manufacturer-store'; |
| 4 | +import { OemCodeStore } from '../store/oem-code-store/oem-code-store'; |
| 5 | +import { StatusStore } from '../store/status-store/status-store'; |
| 6 | +import { UnitSaleStore } from '../store/unit-sale/unit-sale-store'; |
| 7 | +import { WarehouseStore } from '../store/warehouse/warehouse-store'; |
| 8 | +import { PartOriginStore } from '../store/part-origin/part-origin-store'; |
| 9 | + |
| 10 | +@Injectable({ |
| 11 | + providedIn: 'root', |
| 12 | +}) |
| 13 | +export class AppInitializerService { |
| 14 | + private readonly statusStore = inject(StatusStore); |
| 15 | + private readonly oemCodeStore = inject(OemCodeStore); |
| 16 | + private readonly categoryStore = inject(CategoryStore); |
| 17 | + private readonly unitSaleStore = inject(UnitSaleStore); |
| 18 | + private readonly warehouseStore = inject(WarehouseStore); |
| 19 | + private readonly partOriginStore = inject(PartOriginStore); |
| 20 | + private readonly manufacturerStore = inject(ManufacturerStore); |
| 21 | + |
| 22 | + async initialize(): Promise<void> { |
| 23 | + await Promise.all([ |
| 24 | + this.oemCodeStore.loadInitial(), |
| 25 | + this.statusStore.hydrate(), |
| 26 | + this.unitSaleStore.hydrate(), |
| 27 | + this.categoryStore.hydrate(), |
| 28 | + this.warehouseStore.hydrate(), |
| 29 | + this.partOriginStore.hydrate(), |
| 30 | + this.manufacturerStore.hydrate(), |
| 31 | + ]); |
| 32 | + } |
| 33 | +} |
0 commit comments