在我的应用程序中,我对一条数据进行了两次 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 帖子,但我仍然不明白。任何指针表示赞赏。