Driven by Data Style
init:function(){
Dispatcher.on('clickBtnCompare.Foo',this.addSeries);
},
destroy:function(){
Dispatcher.off('clickBtnCompare.Foo');
}
Pull Data Style
clickBtnCompare:function(){
AppCube.DataRepository.fetchNew(storeName).done(function(data){
chart.addSeries(data);
});
}
How about add more one Action?
someTimes:function(){
Dispatcher.on('clickBtnCompare.Foo',this.anotherAction);
}
N(View):1(Model) use notify
1(View):N(Model or State) use fetch
fetch:function(key,state,options){
var store = this._store_list[key];
return store.getState(state,options);
},
fetchNew:function(key,options){
var store = this._store_list[key];
return store.refreshData(options,true);
},
refresh:function(key,options){
var store = this._store_list[key];
store.refreshData(options).done(function(res){
Dispatcher.trigger('refresh:'+key,res,'Component');
});
}
var task = CustomTask.create(taskOptions);
var store = CustomStore.create({
name:storeName,
generator:function(options,taskOptions){
var chart = Dispatcher.request('getParams',{},'Chart');
var params = _.extend({},taskOptions.params,options,chart);
//todo fetch params
return {
params: params
}
}
});
store.setData(task);
store.addState('table',function(res){
return formatter(res);
});