James L James L -4 years ago 58
React JSX Question

Combined async results with React and Redux

I'm working on my first React / Redux app, and I've now reached the first non-trivial problem.

App data (quite a lot of it) is loaded asynchronously from the server on page load, using a default parameter. It's then filtered further on the client side. Both the parameter for the initial data load and the filters may be altered by the user.

One problem I might have is stale data being returned from the initial data load, should the user switch the parameter before it is returned. Another is managing the chain of events in an idiomatic Redux manner.

I'm sure I could manually cancel previous callbacks, but I'm really looking for a more imperative approach.

I would normally solve this sort of problem using RX. Would this be sensible here? In which case, where should my RX code sit?

Thanks for your suggestions

Answer Source

I discovered a library called Redux-Observable, which allows you to view Redux events as event streams, and perform complex async operations as a result. It fits the bill perfectly.

This video got me started

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download