export interface BlogContent {
id: string;
header: string;
tags: string[];
title: string;
actualContent: ActualContent[]; <------ NESTED
}
.
, - :
export interface BlogContents {
byId: { [key: string]: BlogContent };
allIds: string[];
}
export interface BlogContent {
id: string;
actualContentIds: string[];
}
export interface ActualContents {
byId: { [key: string]: ActualContent };
allIds: string[];
}
export interface ActualContent {
id: string;
}
, , :
const blogContentsState: BlogContents = {
byId: {
blogContentId0: {
id: 'idBlogContent0',
actualContentIds: ['actualContentId0', 'actualContentId1', 'actualContentId2']
}
},
allIds: ['blogContentId0']
};
const actualContentState: ActualContents = {
byId: {
actualContentId0: {
id: 'actualContentId0',
},
actualContentId1: {
id: 'actualContentId1',
},
actualContentId2: {
id: 'actualContentId2',
}
},
allIds: ['actualContentId0', 'actualContentId1', 'actualContentId2']
};
(, Angular) , , , , . actualContent: ActualContent[];
.
selector
. , , "" .
const getBlogContents = (blogContentsState, actualContentsState) =>
blogContentsState
.allIds
.map(blogContentId => ({
...blogContentsState.byId[blogContentId],
actualContent: blogContentsState
.byId[blogContentId]
.actualContentIds
.map(actualContentId => actualContentsState.byId[actualContentId])
}));
, , : http://redux.js.org/docs/recipes/reducers/NormalizingStateShape.html
ngrx, , Pizza-Sync. Github. , - :). ( ReduxDevTools, , ).
Redux Pizza-Sync, : https://youtu.be/I28m9lwp15Y