import { inject, Injectable, Provider } from '@angular/core'; import { injectDispatch } from '@ngrx/signals/events'; import { insightsPageEvents } from '../events/insights.events'; import { InsightsStore } from '../stores/insights.store'; /** "Seguimiento": sprint under way, risks, aging and bottlenecks. */ @Injectable() export class InsightsFacade { private readonly store = inject(InsightsStore); private readonly dispatch = injectDispatch(insightsPageEvents); readonly insights = this.store.insights; /** False until the first load: show skeletons, not empty states. */ readonly loaded = this.store.loaded; readonly error = this.store.error; /** * Loads the project's reading and keeps it up to date; with `since` (my * last visit), it also tells what changed after it. */ open(projectId: string, since: string | null = null): void { this.dispatch.opened({ projectId, since }); } } /** Store + facade of the dashboard, for its route component. */ export function provideInsightsFacade(): Provider[] { return [InsightsStore, InsightsFacade]; }