接前一篇,把前面的ListView改成Reflux的形式
var BookActions=Reflux.createActions([ 'fetchList' ]); var BookStore = Reflux.createStore({ listenables: [BookActions], bookList:['item1','item2','item3'], init:function () { this.fetchList(); console.log('init done.'); }, fetchList:function(){ this.bookList.push('item'+(this.bookList.length+1)); console.log('fetchList'+this.bookList.length); this.trigger(this.bookList); } }); var TextItem = React.createClass({ render:function(){ var item = this.props.item; returnthis is {item}
} }); var Template = React.createClass({ render:function(){ return React.createElement(this.props.type,this.props); } }); var ListViewItem = React.createClass({ render:function(){ var item = this.props.item; var cls = this.props.isSelected?'selected':''; if(this.props.template){ return
- { items.map(function (item,i) { var isSelected = (item ==selectedItem); return