Assuming I have a function
function* request(url) {
return global.fetch(url).then(response =>
_.result(response, 'json'))
}
Both code examples work fine to me
const {data} = yield call(request, 'http://example.com/api');
yield put(actionSuccess(data));
and
const {data} = yield request('http://example.com/api');
yield put(actionSuccess(data));
Therefore the question. What is an advantage of using the call
effect for functions that return promises?
SagaTester
approach is used, when a saga is executed natively during unit test, havingcall
doesn't bring any value. – Actino