Convert the product app to NGRX

First, identify your states in the application

  • products (All the products)
  • product (Selected product)
  • error (Optional error to be rendered in case of failure)

I created a folder in the app directory called 'state', inside we have 4 files:

app.state.ts
app.reducer.ts
app.actions.ts
app.effects.ts

in the app.state.ts, I have defined the interface for the global state of the application.

interface State {}

export default State;

What does this mean?

The store with many Feature slices looks like this:

Store<global state>{
	feature1<Feature 1 state>{
					stateVariable1: 1,
					stateVariable2: [1,"Boy"],
					stateVariable3: "Boy",
				},
	feature2<......
}

so we have several levels of states

Discussion

6

0