Adding the dispatcher

Next off we need a dispatcher that is able to take our message, like so:

// demo/dispatcher.jsclass Dispatcher {  constructor() {    this.listeners = [];  }  dispatch(message) {    this.listeners.forEach(listener => listener(message));  }  register(listener) {    this.listeners.push(listener);  }}const dispatcher = new Dispatcher();export default dispatcher;

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.