mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
refactor(stalker): extend portal related store
This commit is contained in:
1 parent
bb0e832b6b
commit
adea3cf0d1
1 file changed
+12
@@ -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<PortalState> {
|
||||
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<PortalState> {
|
||||
searchPhrase,
|
||||
})
|
||||
);
|
||||
|
||||
readonly setContent = this.updater(
|
||||
(state, content: any[]): PortalState => ({
|
||||
...state,
|
||||
content,
|
||||
})
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user