- Architecting Angular Applications with Redux,RxJS,and NgRx
- Christoffer Noring
- 87字
- 2021-08-27 19:56:19
Adding a selected view
This view will register itself with the store and ask for updates to its content. If there are any updates it will be notified and the data from the store will be read and this view will communicate what the store value now is:
// demo/selectedView.js
import store from "./store";
console.log('selected view loaded');
class SelectedView {
constructor() {
this.index = 0;
store.addListener(this.notifyChanged.bind(this));
}
notifyChanged() {
this.index = store.getSelectedItem();
console.log('new index is ', this.index);
}
}
const view = new SelectedView();
export default SelectedView;