From adea3cf0d144e49cfcd832ec52b063d42b1f4e77 Mon Sep 17 00:00:00 2001 From: 4gray <4gray@users.noreply.github.com> Date: Mon, 14 Aug 2023 08:49:20 +0200 Subject: [PATCH] refactor(stalker): extend portal related store --- src/app/xtream/portal.store.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/xtream/portal.store.ts b/src/app/xtream/portal.store.ts index 10c311a7c..299e2a908 100644 --- a/src/app/xtream/portal.store.ts +++ b/src/app/xtream/portal.store.ts @@ -3,6 +3,7 @@ import { ComponentStore } from '@ngrx/component-store'; export interface PortalState { searchPhrase: string; + content: any[]; } @Injectable({ providedIn: 'root' }) @@ -10,12 +11,16 @@ export class PortalStore extends ComponentStore { constructor() { super({ searchPhrase: '', + content: [], }); } // selectors readonly searchPhrase = this.selectSignal((state) => state.searchPhrase); + readonly getContentById = (id: string) => + this.selectSignal((state) => state.content.find((i) => i.id === id)); + // reducers readonly setSearchPhrase = this.updater( (state, searchPhrase: string): PortalState => ({ @@ -23,4 +28,11 @@ export class PortalStore extends ComponentStore { searchPhrase, }) ); + + readonly setContent = this.updater( + (state, content: any[]): PortalState => ({ + ...state, + content, + }) + ); }