3 ms·
My usual approach is to avoid middlewares for async-requests and to keep this stuff in a separate layer. For example, it can look like an ApiClient object with
by indeyets 10y ago
My usual approach is to avoid middlewares for async-requests and to keep this stuff in a separate layer. For example, it can look like an ApiClient object with ES7 async-methods. Such methods would:
1. send "Start" action
2. await for result of fetch("http://example.com/api/call"); http://example.com/api/call");
3. send success or error action
this way redux is 100% synchronous and I have an obvious place for throttling requests, keeping trace of promises, etc.