Answer the question
In order to leave comments, you need to log in
How to type redux-saga?
Usually there is no problem finding information about how to type a library, but in the case of sagas, there is almost no information at all.
I did not find anywhere how to type what will return back to the generator. Can it be done?
Answer the question
In order to leave comments, you need to log in
At work, we type with flow, maybe it will help you, with something
// @flow
import { call, put, takeEvery } from 'redux-saga/effects';
import { setupSagaTarget } from '@work-util';
import { fetchApi } from './api';
import * as constants from '../constants'
import * as actions from '../actions';
/**
* Fetch card data Saga
* @returns {void}
*/
export function* fetchCData(): Iterator<*> {
const data = yield call(fetchApi);
if (data) {
yield put(actions.success(data));
}
}
export function* watchFetchRequest(): Iterator<*> {
yield takeEvery(constants.APP_REQUEST, fetchData);
}
const sagas = [
setupSagaTarget(watchFetchRequest, true, true),
];
export { sagas };
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question