Files
freeCodeCamp/client/src/redux/donation-saga.js

21 lines
538 B
JavaScript
Raw Normal View History

import { put, select, takeEvery, delay } from 'redux-saga/effects';
import {
openDonationModal,
preventDonationRequests,
shouldRequestDonationSelector
} from './';
function* showDonateModalSaga() {
let shouldRequestDonation = yield select(shouldRequestDonationSelector);
if (shouldRequestDonation) {
yield delay(200);
yield put(openDonationModal());
yield put(preventDonationRequests());
}
}
export function createDonationSaga(types) {
return [takeEvery(types.tryToShowDonationModal, showDonateModalSaga)];
}