Now that we have an Angular 2+ project set up, it's time to connect it to Redux:
- We start by copying over the following files from the second chapter (chapter2_4.zip) and pasting them into the src/app/ directory. Ensure that you change the file ending to .ts. TypeScript is compatible with ES6 syntax, so our code will work fine. Copy over the following files from chapter2_4.zip:
- actionTypes.js → src/app/actionTypes.ts
- actions.js → src/app/actions.ts
- reducers.js → src/app/reducers.ts
- Then, we install redux and @angular-redux/store via npm:
npm install --save redux @angular-redux/store
Since we are using TypeScript, we first need to define our app state as an interface.
- Create a new src/app/types.ts file. ...