redux-saga/effects#takeEvery TypeScript Examples
The following examples show how to use
redux-saga/effects#takeEvery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
export function* watchAssignLeaveActions() {
yield takeEvery(ASSIGN_SINGLE_DAY_LEAVE_REQUEST, saveLeaveRequest);
yield takeEvery(ASSIGN_MULTIPLE_DAY_LEAVE_REQUEST, saveLeaveRequest);
yield takeEvery(
FETCH_SUBORDINATE_LEAVE_ENTITLEMENT,
fetchSubordinateLeaveEntitlements,
);
yield takeEvery(FETCH_SUBORDINATES, fetchAccessibleEmployees);
yield takeEvery(FETCH_WORK_SHIFT, fetchWorkShift);
yield takeEvery(FETCH_LEAVE_TYPES, fetchLeaveTypes);
}
Example #2
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 6 votes |
function* getAdminUsersSaga() {
yield takeEvery(actionTypes.GET_ADMIN_USERS, function* _() {
yield put({
type: loadingActionTypes.START_LOADING,
});
yield call(getAccessTokenSaga);
try {
const res = yield call(getAdminUsers);
const data = res.data.map((item: any) => {
return {
...item,
createdAt: item.createdAt ? item.createdAt._seconds : null
}
})
yield put({
type: actionTypes.GET_ADMIN_USERS_SUCCESS,
payload: {
listData: data,
},
});
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.status, errorMessage: error.error },
});
}
yield put({
type: loadingActionTypes.END_LOADING,
});
});
}
Example #3
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 6 votes |
function* deleteAdminUserSaga() {
yield takeEvery(actionTypes.DELETE_ADMIN_USER, function* _({
payload,
}: {
type: string;
payload: { id: string };
}) {
yield put({ type: loadingActionTypes.START_LOADING });
yield call(getAccessTokenSaga);
try {
yield call(deleteAdminUser, payload);
yield put({ type: actionTypes.DELETE_ADMIN_USER_SUCCESS });
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'deleteSuccess' },
});
yield put({
type: actionTypes.GET_ADMIN_USERS,
});
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.status, errorMessage: error.error },
});
}
yield put({ type: loadingActionTypes.END_LOADING });
});
}
Example #4
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 6 votes |
function* loginSaga() {
yield takeEvery(actionTypes.LOGIN, function* _({ payload }: any) {
yield put({ type: loadingActionTypes.START_LOADING });
const { email } = payload;
yield call(sendEmailSaga, email);
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'loginByAuthLink' },
});
yield put({ type: loadingActionTypes.END_LOADING });
yield payload.callback();
});
}
Example #5
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 6 votes |
function* logoutSaga() {
yield takeEvery(actionTypes.LOGOUT, function* _({ payload }: any) {
yield put({ type: loadingActionTypes.START_LOADING });
try {
yield call([auth, auth.signOut]);
yield localStorage.removeItem('token');
yield localStorage.removeItem('userAdminRole');
yield localStorage.removeItem('email');
yield put({
type: actionTypes.LOGOUT_SUCCESS,
});
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'logoutSuccess' },
});
payload.callback();
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.code, errorMessage: error.message },
});
}
yield put({ type: loadingActionTypes.END_LOADING });
});
}
Example #6
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
export function* watchAttendanceActions() {
yield takeEvery(FETCH_LEAVE_RECORDS, fetchLeaveRecords);
yield takeEvery(FETCH_ATTENDANCE_RECORDS, fetchAttendanceRecords);
yield takeEvery(FETCH_ATTENDANCE_GRAPH_RECORDS, fetchAttendanceGraphRecords);
yield takeEvery(FETCH_HOLIDAYS, fetchHolidays);
yield takeEvery(FETCH_WORK_WEEK, fetchWorkWeek);
yield takeEvery(FETCH_EMPLOYEE_ATTENDANCE_LIST, fetchEmployeeAttendanceList);
yield takeEvery(FETCH_ATTENDANCE_CONFIGURATION, fetchAttendanceConfiguration);
yield takeEvery(FETCH_SUBORDINATES, fetchAccessibleEmployees);
}
Example #7
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
export function* watchAuthActions() {
yield takeEvery(FETCH_TOKEN, fetchAuthToken);
yield takeEvery(LOGOUT, logout);
yield takeEvery(FETCH_MY_INFO, fetchMyInfo);
yield takeEvery(CHECK_INSTANCE, checkInstance);
yield takeEvery(FETCH_ENABLED_MODULES, fetchEnabledModules);
yield takeEvery(FETCH_NEW_TOKEN_FINISHED, fetchApiDefinition);
yield takeEvery(FETCH_MY_INFO, fetchApiDefinition);
}
Example #8
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 6 votes |
function* getMessagesSaga() {
yield takeEvery(actionTypes.GET_MESSAGES, function* _() {
yield put({ type: loadingActionTypes.START_LOADING });
yield call(getAccessTokenSaga);
try {
const res = yield call(getPrefectures);
const data = res.data.map((item: PrefectureMessage) => {
return {
...item,
url: item.message,
id: item.prefectureId,
};
});
yield put({
type: actionTypes.GET_MESSAGES_SUCCESS,
payload: {
listData: data,
},
});
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.status, errorMessage: error.error },
});
}
yield put({ type: loadingActionTypes.END_LOADING });
});
}
Example #9
Source File: saga.ts From react-js-tutorial with MIT License | 6 votes |
export function* chatSaga() {
const socket = yield call(createWebSocketConnection);
const socketChannel = yield call(createSocketChannel, socket);
yield takeEvery(actions.send.type, sendMessage, socket);
while (true) {
try {
const payload = yield take(socketChannel);
yield put(actions.update([payload]));
} catch (err) {
console.error("socket error:", err);
socketChannel.close();
}
}
}
Example #10
Source File: index.ts From camus with GNU Affero General Public License v3.0 | 6 votes |
export default function* rootSaga() {
yield takeLatest(setUsername.type, doSetUsername);
yield takeEvery(sendChatMessage.type, doSendChatMessage);
yield takeLatest(setLocalAudio.type, doSetLocalAudio);
yield takeLatest(setLocalVideo.type, doSetLocalVideo);
yield takeLatest(setResolution.type, doSetResolution);
yield takeLatest(disableRemoteVideo.type, doDisableRemoteVideo);
yield takeLatest(enableRemoteVideo.type, doEnableRemoteVideo);
yield takeEvery(addIceServer.type, doSetIceServers);
yield takeEvery(removeIceServer.type, doSetIceServers);
yield takeEvery(updateIceServer.type, doSetIceServers);
}
Example #11
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchSetStorageItem() {
yield takeEvery(SET_ITEM, setItemAsyncStorage);
yield takeEvery(SET_MULTI, setMultiAsyncStorage);
}
Example #12
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchCommonScreensActions() {
yield takeEvery(FETCH_HOLIDAYS, fetchHolidays);
yield takeEvery(FETCH_WORK_WEEK, fetchWorkWeek);
}
Example #13
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchLeaveListActions() {
yield takeEvery(FETCH_LEAVE_LIST, fetchLeaveList);
yield takeEvery(FETCH_EMPLOYEE_LEAVE_REQUEST, fetchEmployeeLeaveRequest);
yield takeEvery(
CHANGE_EMPLOYEE_LEAVE_REQUEST_STATUS,
changeEmployeeLeaveRequestStatus,
);
}
Example #14
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchLeaveUsageActions() {
yield takeEvery(FETCH_MY_LEAVE_ENTITLEMENT, fetchMyLeaveEntitlements);
yield takeEvery(FETCH_MY_LEAVE_REQUEST, fetchMyLeaveRequests);
yield takeEvery(FETCH_MY_LEAVE_DETAILS, fetchMyLeaveDetails);
yield takeEvery(CHANGE_MY_LEAVE_REQUEST_STATUS, changeMyLeaveRequestStatus);
}
Example #15
Source File: saga.ts From react-js-tutorial with MIT License | 5 votes |
export function* gameSaga() {
yield fork(watchAndLog);
yield fork(watchFirstThreeAction);
yield takeEvery(actions.click.type, gameStateWatcher);
}
Example #16
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchPunchStatusActions() {
yield takeEvery(FETCH_PUNCH_STATUS, fetchPunchStatus);
yield takeEvery(PUNCH_IN_REQUEST, savePunchInRequest);
yield takeEvery(PUNCH_OUT_REQUEST, savePunchOutRequest);
}
Example #17
Source File: sagas.ts From waifusion-site with MIT License | 5 votes |
/* WATCHERS */
function* watchLoadWaifus() {
yield takeEvery(loadWaifus, loadWaifusAction);
}
Example #18
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchApplyLeaveActions() {
yield takeEvery(APPLY_SINGLE_DAY_LEAVE_REQUEST, saveLeaveRequest);
yield takeEvery(APPLY_MULTIPLE_DAY_LEAVE_REQUEST, saveLeaveRequest);
yield takeEvery(FETCH_WORK_SHIFT, fetchWorkShift);
}
Example #19
Source File: sagas.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
export function* watchHelpConfigActions() {
yield takeEvery(FETCH_HELP_CONFIG, fetchConfigHelp);
}
Example #20
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 5 votes |
function* updateMessageSaga() {
yield takeEvery(actionTypes.UPDATE_MESSAGE, function* _({
payload,
}: {
type: string;
payload: UpdatePrefectureRequestDto;
}) {
const { url, id } = payload;
yield put({ type: loadingActionTypes.START_LOADING });
yield call(getAccessTokenSaga);
try {
yield call(patchPrefecture, {
id,
message: url ? url : '',
});
const { listData } = yield select((state) => state.prefectureMessage);
const { userAdminRole } = yield select((state) => state.auth);
if (userAdminRole === 'PREFECTURE_ADMIN_ROLE') {
listData[0].url = payload.url;
} else {
listData[parseInt(payload.id, 10)].url = payload.url;
}
yield put({
type: actionTypes.UPDATE_MESSAGE_SUCCESS,
payload: { listData },
});
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'submitSuccess' },
});
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.status, errorMessage: error.error },
});
}
yield put({ type: loadingActionTypes.END_LOADING });
});
}
Example #21
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 5 votes |
function* showErrorMessageSaga() {
yield takeEvery(actionTypes.SHOW_ERROR_MESSAGE, function* _() {
yield delay(3000);
yield put({ type: actionTypes.CLOSE_ERROR_MESSAGE });
});
}
Example #22
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 5 votes |
function* showSuccessMessageSaga() {
yield takeEvery(actionTypes.SHOW_SUCCESS_MESSAGE, function* _() {
yield delay(3000);
yield put({ type: actionTypes.CLOSE_SUCCESS_MESSAGE });
});
}
Example #23
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 5 votes |
function* autoSignInSaga() {
yield takeEvery(actionTypes.AUTO_SIGN_IN, function* _({ payload }: any) {
if (auth.isSignInWithEmailLink(window.location.href)) {
yield put({ type: loadingActionTypes.START_LOADING });
let email = localStorage.getItem('emailForSignIn');
if (!email) {
email = window.prompt(langLocales[langCode]['emailConfirmPrompt']);
}
if (email) {
try {
yield call(signInWithEmailLink, email);
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.code, errorMessage: error.message },
});
}
}
const user = yield call(onAuthStateChanged);
if (user) {
const defaultToken = yield call([user, user.getIdToken]);
yield put({
type: actionTypes.SAVE_TOKEN_SUCCESS,
payload: { token: defaultToken },
});
try {
yield call(login);
if (auth.currentUser) {
yield call(getAccessTokenSaga);
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'loginSuccess' },
});
payload.callback();
}
} catch (error) {
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: { errorCode: error.status, errorMessage: error.error },
});
}
}
yield put({ type: loadingActionTypes.END_LOADING });
}
});
}
Example #24
Source File: saga.ts From mamori-i-japan-admin-panel with BSD 2-Clause "Simplified" License | 5 votes |
function* createAdminUserSaga() {
yield takeEvery(actionTypes.CREATE_ADMIN_USER, function* _({ payload }: any) {
const { email, role: adminRole, organization, prefecture } = payload.data;
yield put({
type: loadingActionTypes.START_LOADING,
});
yield call(getAccessTokenSaga);
const requestBody: any = {
email,
adminRole: adminRoleList[adminRole],
};
if (organization) {
requestBody.organizationId = organization;
}
if (prefecture) {
requestBody.prefectureId = Number.parseInt(prefectureList[prefecture].id);
}
try {
yield call(postAdminUser, requestBody);
yield call(sendEmailSaga, email);
yield put({
type: feedbackActionTypes.SHOW_SUCCESS_MESSAGE,
payload: { successMessage: 'createAdminUserSuccess' },
});
payload.callback();
} catch (error) {
const errorMessage = error.status === 409 ? 'adminUserIsExistError' : error.error;
yield put({
type: feedbackActionTypes.SHOW_ERROR_MESSAGE,
payload: {
errorCode: error.status,
errorMessage: errorMessage
}
});
}
yield put({
type: loadingActionTypes.END_LOADING,
});
});
}