[question] What is the point?
Currently the library just lets to write
dispatch(x);
dispatch(y);
as
dispatch([x, y]);
But I don't see why do I need a library for that. Even Promise.all is not a reason for another library. If this middleware have sent a store update event after all the updates once, it would make sense, but (surprisingly) it doesn't. So, what is the point?
I think the point is to use it with redux-promise. Similar technic is used in F8 app by Facebook. See https://github.com/fbsamples/f8app/blob/master/js/actions/login.js#L80
This package is included in F8 here: https://github.com/fbsamples/f8app/blob/master/js/store/array.js
@mucsi96 That's just a call to Promise.all. You don't need any middleware to do that call.
Ok but then what is the point for the https://github.com/fbsamples/f8app/blob/master/js/store/array.js file?
After every promise is resolved wrapped in Promise.all we will get an array of actions. Redux cannot handle that. You have map over every action and pass it to redux again using next
store => next => action =>
Array.isArray(action)
? action.map(next)
: next(action);
@mucsi96 File is not npm package. Being a Facebook employee doesn't imply you're doing it right. You can always use
const mapNext = require('../store/array.js');
const mapped = mapNext(list);
or
const mapped = list.map(next);
whichever is shorter for your purposes.
How can you do for example 2 requests to the backend with that? How should the store configuration and the action dispatcher look like?