【发布时间】:2015-03-12 21:30:16
【问题描述】:
在我的应用程序中,我对一条数据进行了两次 ajax 调用。首先,我拨打电话以获取ecommerceIntegrations 的列表。一旦我有了这些,我就可以抓住他们各自的orders。
我当前的代码如下所示:
componentDidMount: function() {
EcommerceIntegrationStore.addChangeListener(this._onIntegrationStoreChange);
OrderStore.addChangeListener(this._onOrderStoreChange);
WebshipEcommerceIntegrationActionCreators.getEcommerceIntegrations();
},
_onIntegrationStoreChange: function() {
var ecommerceIntegrations = EcommerceIntegrationStore.getEcommerceIntegrations();
this.setState({ecommerceIntegrations: ecommerceIntegrations});
ecommerceIntegrations.forEach(function(integration) {
WebshipOrderActionCreators.getPendingOrdersOfIntegration(integration.id);
});
},
_onOrderStoreChange: function() {
this.setState({
pendingOrders: OrderStore.getAllPendingOrders(),
pendingOrdersByIntegration: OrderStore.getPendingOrdersByIntegration()
});
}
我正在尝试遵循 Facebook 的 Flux 模式,但我很确定这不会遵循它。我看到其他一些关于使用 Flux 嵌套数据的 SO 帖子,但我仍然不明白。任何指针表示赞赏。
【问题讨论】:
标签: reactjs reactjs-flux