#reactjs #redux #async-await #redux-saga
Вопрос:
Использование функции Redux Saga для промежуточного программного обеспечения. выход требуется для асинхронной работы, но я хочу сделать вызов в фоновом режиме, например, logger
как в приведенной ниже функции , я только что добавил тег «Вопрос», требуется ли для вызова yield
?
function* ProcessTask({payload})
{
try
{
yield put(loader.show(DATA));
const taskData = yield select(selectTask);
// Question: Is it required to add YIELD here ? its just a function without async operation (I see no difference with or without)
const prepareRequestPayload = prepareRequestPayload( payload, taskData);
// Question: Do I need to call with Yield here ? I don't need to hold the execution for logger. It is making API call internally as asyn. Just for performance, want to get in background without holding execution).
logMessage('request payload created', prepareRequestPayload);
const result = yield Service.RequestTask(prepareRequestPayload);
...
..
..
}
catch(err)
{
// Same as above `logMessage`, logError is making API call internally , Does it needs to be call with yield ? I don't want to hold execution for logError as its just logging.
logError('error occured',err);
}
}