I have an app that displays blogs using ngrx
The main root state is as follows
import { Blog } from '../models/blog';
export interface AppState {
readonly loaded: boolean;
readonly blogs: {[key:number]:Blog}
}
export const initialState:AppState = {
loaded: false,
blogs: {}
}
I also have a feature module set up to administrate the blogs
StoreModule.forFeature('crudBlog', reducers)
What I'm wondering about now is; when I want to update, delete etc. a blog how do I get access to the AppState (root state) of my store from the feature reducer file
So I can do something like this;
function handleBlogUpdatedAction(state, action){
const index = action.payload.index;
const newState = Object.assign({}, rootState);
newState[index] = action.payload.blog
return newState;
}
Or is there a better way?