Adding a store

A store at its heart is just a class wrapping a state. A store needs to be able to deal with changes;  the change should come via method dispatch. The following pseudo code represents what the store might look like:

// NGRX-light/storeI.jsclass Store {  constructor() {    this.state = {};  }  dispatch() {   // calculate the new state and replace the old one  }}

We mentioned in the beginning of this main section that NgRx uses RxJS at its core. We mentioned that it was so the store could convey changes to its listeners. Let's mention the core concepts of RxJS that might fit the preceding problem description. In RxJS, we have:

  • Observable: It is able to emit values and you can attach subscribers to it
  • Observer: This is the object that ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.