Using the reduction saga, you can simultaneously perform several effects:
import { call } from 'redux-saga/effects'
const [users, repos] = yield [
call(fetch, '/users'),
call(fetch, '/repos')
]
How can I create these "call" calls programmatically ?
What I want to achieve:
Suppose I have an array with different parameters, and I want to execute a request to the server for one parameter, but in parallel with the sound reduction:
const parameters = ['abc', 'def', 'ghi']
const allMyFetchCalls = parameters.map( (p) => makeCallRequestWithParameter(p) );
makeCallRequestWithParameter will create a function call (or in the case of reduction-saga-speech: effect) (selection, parameter), as in a yield call (selection, parameter)
const resultArray = yield allMyFetchCalls;
Is this possible, and if so, how?
source
share