0

I'm working on a ReactJS + Flux application. The application allows a user to submit a post. This post may take a number of seconds to upload to the server, and I want to display a progress bar.

The current flow is: action method called with post data -> dispatcher -> post store -> ??? -> update post UI to show progress bar.

The question marks would be an emitted event. My question is: is it an anti-pattern to use an event other than "change"? I'd like to be more specific (for example, emitting "progress") so that I can do less work in the view to determine if there has been progress.

2 Answers 2

1

I don't think there's any need to introduce new event types, and doing so will probably make it harder to keep track of data flow as the app grows. It seems like this can be handled using the normal design patterns. If progress is being calculated client-side, you can do it in the action creator itself (e.g. click-handler that sends the post request) and just emit a series of PROGRESS actions to update your stores and let your views refresh as needed.

1
  • I'll try this out later - if it works and follows flux design patterns then I think it can be accepted answer. Thank you!
    – iLoch
    Feb 2, 2015 at 19:45
0

Ultimately, I think something like a progress indicator is the responsibility of the view to keep up-to-date.

The way I've been handling cases like this is by having the Store record the time that the Post was started. Then in the UI, you can read that timestamp from the store and set up a interval to get the current timestamp and calculate the delta.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.