11 ms·
I always put a `pending` property on the `meta` object, and any component that needs to show network status can just check that property on every render cycle.
by pault 9y ago
I always put a `pending` property on the `meta` object, and any component that needs to show network status can just check that property on every render cycle. Aside from requiring some extra utility functions in the reducers to prevent having to updating `pending` for every state of the request it's rock solid and I haven't ever encountered a situation where it wouldn't work. You can get a _lot_ of mileage out of conforming to the FSA standard[1]; network status goes in meta, and errors are always handled the same way.
[1] https://github.com/redux-utilities/flux-standard-action https://github.com/redux-utilities/flux-standard-action
- adamsea 9y agoAgreed. And that sounds like a great approach. We didn’t conform exactly to FSA (which I want to try out on future projects). Our isWaiting was equivalent to your pending, I think. (Edit) FYI we had actions to set isWaiting, etc.
- adamsea 9y agoAlso, this conversation got me thinking about the difference between application state, state of an asynchronous request, and Redux actions as events (I'm thinking of the request/response events in node.js), and using them as such - to pass data throughout the application (in addition to the payload). Which I guess is what FSA is all about? So, thank you!