Hacker Newsnew | past | comments | ask | show | jobs | submit | raxis's commentslogin

The isEatingBurger (isLoading) flag seems to be idiomatic in Redux and shows up in tutorials. In addition to preventing overlapping requests, it's useful for spinners, disabling submit buttons, etc. It's cool that you rolled the isLoading pattern into a service.

If you really want to pass around the promise, it's doable. To save in your component state, return the promise from your thunk so it gets returned by dispatch (thom_nic just posted this also). To save in your store, dispatch a 'save' action from the thunk with the promise as an argument. But I agree that it's probably a bad design.

The request sequence IDs are useful for many situations where you need to order or cancel async requests. If you have multiple in-flight requests for an autocomplete field, you only want to set isLoading=false when the last request completes, and you don't want the result of a later request to overwrite the result of an earlier request if the responses come back out-of-order.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: