The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Angular 1.x Redux: Subscribe to the Application Store

Angular 1.x Redux: Subscribe to the Application Store

5:59
In this lesson, we are going to extend our application store with a subscribe method so that we do not have to manually query our application store every time we dispatch an action. In our categories controller, we are dispatching a **GET_CATEGORIES** action every time we want to update the categories collection within our application store. For this change to be propagated back into our controller, we need to call **store.getState**. Depending on how many times we are calling **store.dispatch**, this could get very cumbersome. We will extend our application by adding a subscribe method so that state changes are automatically pushed into our controller.
Watch this lesson now
Avatar
egghead.io

In this lesson, we are going to extend our application store with a subscribe method so that we do not have to manually query our application store every time we dispatch an action.

In our categories controller, we are dispatching a GET_CATEGORIES action every time we want to update the categories collection within our application store. For this change to be propagated back into our controller, we need to call store.getState.

Depending on how many times we are calling store.dispatch, this could get very cumbersome. We will extend our application by adding a subscribe method so that state changes are automatically pushed into our controller.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?