官术网_书友最值得收藏!

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;
主站蜘蛛池模板: 崇左市| 广水市| 资源县| 涟水县| 长春市| 兰西县| 密山市| 黑水县| 奉节县| 新郑市| 陇西县| 晋江市| 鸡西市| 台南县| 金寨县| 昭苏县| 青州市| 五台县| 自治县| 榕江县| 仁寿县| 西乌| 宁津县| 龙岩市| 麻城市| 江陵县| 荔波县| 天等县| 勃利县| 平山县| 高陵县| 天等县| 中阳县| 余庆县| 勃利县| 鹤庆县| 文登市| 运城市| 辰溪县| 金溪县| 镇雄县|