Open web-dave opened 7 years ago
npm i -S @ngrx/store
npm i -D @ngrx/store-devtools
import { Action } from "@ngrx/store";
import { IBook } from "../shared/custom-types";
export const booksStoreName = "books";
export interface BooksState {
books: IBook[];
}
export const initialState: BooksState = {
books: []
};
export function booksReducer(state = initialState, action: Action): BooksState {
return state
}
import { StoreModule } from "@ngrx/store";
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
...
@NgModule({
declarations: [...],
imports: [
...,
StoreModule.forRoot({}),
StoreDevtoolsModule.instrument({ maxAge: 100 })
],
...
})
export class AppModule {
...
}
import { StoreModule } from "@ngrx/store";
...
@NgModule({
declarations: [...],
imports: [
...,
StoreModule.forFeature(booksStoreName, {
books: booksReducer
})
],
...
})
export class BooksModule {
...
}
@ngrx/store