I am trying to implement a feature state which has a graph state, two subfeatures: a node state and a link state;
the graph state and reducer I am implementing it like this:
export interface GraphState {
[fromNode.featureKey]: fromNode.State;
[fromLink.featureKey]: fromLink.State;
}
export interface AppState extends fromRoot.State {
readonly [featureKey]: GraphState;
}
export const reducers: ActionReducerMap<GraphState> = {
[fromNode.featureKey]: fromNode.reducer,
[fromLink.featureKey]: fromLink.reducer,
};//The main reducer
//feature module
StoreModule.forFeature(fromGraph.graphsFeatureKey, fromGraph.reducers),
//components that use this store
private _store: Store<fromGraph.AppState>
this._nodes$ = this._store.pipe(select(fromGraph.getNodes));
this._links$ = this._store.pipe(select(fromGraph.getLinks));
this._store.dispatch(fromGraphActions.AddNode({ node }));
and it is doing fine; but now I am learning Entity, and I've read some posts, it seems that the way I implemented is not correct.
How do I implement this using Entity correctly?
I want the components can CRUD the node and link from the main feature which is the graph feature, and I want to select graph to get the nodes and links at once this.nodesAndLinks$ = this._store.pipe(select(fromGraph.getNodesAndLinks))