Creating our second controller class – list-view.js

Let's now shift our focus to our list-view.js file that we are yet to create:

// dataflow/list-view.jsimport { createItem } from "./actions";import { select, subscribe } from "./redux";console.log("list item view has loaded");class ListItemsView {  constructor() {    this.render();    subscribe(this.render);  }  render() {    const items = select("items");    const elem = document.getElementById("list");    elem.innerHTML = "";    items.forEach(item => {      const li = document.createElement("li");      li.innerHTML = item.title;      elem.appendChild(li);    });  }}const listItemsView = new ListItemsView();export default listItemsView;

OK, so we utilize the select() method and get a slice of state from our state from the redux.js ...

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.