Today we'll learn how to use Redux with Angular X. The main goals of our lab are:
Actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using store.dispatch()
Actions describe the fact that something happened, but don't specify how the application's state changes in response. This is the job of reducers.
The Store is the object that brings them together. The store has the following responsibilities:
getState()
dispatch(action)
subscribe(listener)
subscribe(listener)
Redux architecture revolves around a strict unidirectional data flow.
The state of your whole application is stored in an object tree within a single store.
The only way to change the state is to emit an action, an object describing what happened.
To specify how the state tree is transformed by actions, you write pure reducers.
git
and node
installed.
Then,
git clone https://github.com/intelliware-coe-web/lab-angular-redux.git
npm install
npm start
Checkout the feat-people-details branch, and look for the following comments:
// LAB: Step 1 - Add new action type
// LAB: Step 2 - Create new action
// LAB: Step 3 - Generate new immutable state
// LAB: Step 4 - Dispatch the action
// LAB: Step 5 - Update people field
Note: If you're struggling, you can still checkout the tags/feat-people-details-solution tag.
git checkout tags/feat-people-details-solution
Here's the API: https://swapi.co/api/planets