1 year ago
#377298
underfrankenwood
Redux saga race effect in pure javascript
In redux saga we have race
effect where we can pass named promises:
const { a, b } = yield race({ // will resolve if one of them resolves
a: call(somePromise),
b: call(somePromise2),
});
if (a) {
// do something because "a" resolved
}
if (b) {
// do something because "b" resolved
}
Question: Is there a way to implement such thing in pure javascript?
const { a, b } = Promise.race({
a: somePromise1,
b: somePromise2,
});
but this will fail because Promise.race
accepts only arrays. Is there a way to make it work as redux saga?
javascript
reactjs
ecmascript-6
es6-promise
redux-saga
0 Answers
Your Answer