0

What is the best way to manage a "multiple request" using react+flux. I'm using a file upload component that manages it's own request. I have more than one in the form. I need to ask for the upload components to make their requests and save my form just after I'm sure all uploads were ok.

I normally use the api to make requests, called by actions. I dispatch an event to indicate the beginning on the action and another to indicate the end on the api. But, how to manage this "multi requests" scenario?

Any ideas?

Bruno Reis
  • 326
  • 2
  • 7

1 Answers1

0

You can chain your actions together. For example:

  1. User action triggers Action 1

  2. Action 1 triggers API request 1

  3. API response 1 triggers Action 2

  4. Action 2 triggers API request 2

  5. API response 2 triggers Action 3

  6. Action 3 updates the UI

This means that you can compose your API requests together as and when business requirements change.

Clarkie
  • 7,490
  • 9
  • 39
  • 53
  • Thanks. Let me explain a little more. I have a list and a form in the same page. I save the form. When it finishes, I want to reload the list. But, the sate of the list component (and the store) contains the actual filtering data. How do I grab that data from the list of from the store? Should the API grab this data from the store to pass to the action? – Bruno Reis Sep 09 '15 at 21:29
  • Another related question... I'm using browserify and including files with "require(xxx)" statements. In that case, if I require the api in the actionCreator and require the actionCreator in the api, I'll get a circular dependency problem. Any hints on that? – Bruno Reis Sep 09 '15 at 21:31
  • I found the answer to my question here in the comments. I didn't know I could access stores from web api tools. Now I know I can. That makes things a lot easier. – Bruno Reis Sep 11 '15 at 16:30