私のアプリでは、1 つのデータに対して 2 つの 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 の投稿を見ましたが、まだ理解できません。任意のポインタをいただければ幸いです。