redux-saga/effects#all JavaScript Examples

The following examples show how to use redux-saga/effects#all. 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: saga.js    From bank-client with MIT License 6 votes vote down vote up
export function* getAvailableFunds() {
  try {
    const [{ amountMoney, currencyName }, accountBalanceHistory] = yield all([
      call(getAmountMoney),
      call(getAccountBalanceHistory),
    ]);

    yield put(
      getAvailableFundsSuccessAction(
        amountMoney,
        currencyName,
        accountBalanceHistory,
      ),
    );
  } catch (error) {
    yield put(getAvailableFundsErrorAction(error));
    yield put(push(routes.login.path));
  }
}
Example #2
Source File: sagas.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
function * handleFetchWallet (action) {
  yield put(globalActions.setFetchStatus(true))
  try {
    const { address } = action.payload
    const wallet = yield call(api.blockchain.getWallet, { address })
    let backlinks = []
    let forwardAddress = null
    let oldInfos = []
    let identificationKeys = []
    if (wallet?.majorVersion >= 9) {
      backlinks = yield call(api.blockchain.getBacklinks, { address })
      forwardAddress = yield call(api.blockchain.getForwardAddress, { address })
    }
    if (wallet?.majorVersion >= 14) {
      oldInfos = yield call(api.blockchain.getOldInfos, { address })
    }
    if (wallet?.majorVersion >= 15) {
      identificationKeys = yield call(api.blockchain.getIdentificationKeys, { address })
    }
    yield all([
      put(walletActions.fetchWalletSuccess({ ...wallet, backlinks, forwardAddress, oldInfos, identificationKeys })),
      put(globalActions.setFetchStatus(false)),
    ])
  } catch (err) {
    console.error(err)
    yield all([
      put(globalActions.setFetchStatus(false)),
      put(globalActions.setError(new Error('Failed to get wallet information'))),
    ])
  }
}
Example #3
Source File: root.sagas.js    From react-redux-jsonplaceholder with MIT License 6 votes vote down vote up
export default function* rootSaga() {
  yield all([
    call(albumsSaga),
    call(commentsSaga),
    call(photosSaga),
    call(postsSaga),
    call(todosSaga),
    call(usersSaga),
  ]);
}
Example #4
Source File: sagas.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
function * handleFetchPrice () {
  yield put(globalActions.setFetchStatus(true))
  try {
    const price = yield call(api.binance.getPrice)
    yield all([
      put(globalActions.fetchPriceSuccess(price)),
      put(globalActions.setFetchStatus(false)),
    ])
  } catch (err) {
    console.error(err)
    yield all([
      put(globalActions.setFetchStatus(false)),
      put(globalActions.setError(new Error('Failed to get ONE/USDT price'))),
    ])
  }
}
Example #5
Source File: user.js    From full-stack-fastapi-react-postgres-boilerplate with MIT License 6 votes vote down vote up
/**
 * User Sagas
 */
export default function* root() {
  yield all([
    takeLatest(ActionTypes.USER_LOGIN, login),
    takeLatest(ActionTypes.USER_LOGOUT, logout),
  ]);
}
Example #6
Source File: root.saga.js    From horondi_admin with MIT License 6 votes vote down vote up
export function* rootSaga() {
  yield all([
    historySaga(),
    newsSaga(),
    authSaga(),
    themeSaga(),
    categorySaga(),
    usersSaga(),
    materialSaga(),
    patternSaga(),
    businessPagesSaga(),
    productsSaga(),
    contactsSaga(),
    commentsSaga(),
    sizesSaga(),
    homePageSaga(),
    emailQuestionSaga(),
    statsSaga(),
    modelSaga(),
    headerSaga(),
    ordersSaga(),
    homePageSlideSaga(),
    colorsSaga(),
    constructorSaga(),
    snackbarSaga(),
    backSaga(),
    bottomSaga(),
    snackbarSaga(),
    pocketsSaga(),
    positionSaga(),
    closuresSaga(),
    strapsSaga(),
    currenciesSaga(),
    basicsSaga(),
    questionsAnswersSaga()
  ]);
}
Example #7
Source File: constructor.sagas.js    From horondi_client_fe with MIT License 6 votes vote down vote up
export function* constructorSaga() {
  yield all([
    constructorBasicSaga(),
    constructorBottomSaga(),
    constructorFrontPocketSaga(),
    constructorModelSaga(),
    constructorPatternSaga(),
    constructorSizeSaga()
  ]);
}
Example #8
Source File: sagas.js    From what-front with MIT License 6 votes vote down vote up
export function* authWatcher() {
  yield all([
    fork(loginWatcher),
    fork(logOutWatcher),
    fork(registrationWatcher),
    fork(fetchAssignedUserListWatcher),
    fork(fetchUnAssignedUserListWatcher),
    fork(changePasswordWatcher),
    fork(forgotPasswordWatcher),
    fork(resetPasswordWatcher),
  ]);
}
Example #9
Source File: sagas.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
function * handleFetchTokenBalance (action) {
  yield put(globalActions.setFetchStatus(true))
  try {
    const { address, contractAddress, tokenType, tokenId, key } = action.payload
    const balance = yield call(api.blockchain.tokenBalance, { contractAddress, tokenType, tokenId, address })
    yield all([
      put(balanceActions.fetchTokenBalanceSuccess({ address, key, balance: balance.toString() })),
      put(globalActions.setFetchStatus(false)),
    ])
  } catch (err) {
    console.error(err)
    yield all([
      put(globalActions.setFetchStatus(false)),
      put(globalActions.setError(new Error('Failed to get wallet balance'))),
    ])
  }
}
Example #10
Source File: actions.js    From what-front with MIT License 6 votes vote down vote up
export function* coursesWatcher() {
  yield all([
    fork(fetchActiveCoursesWatcher),
    fork(fetchNotActiveCoursesWatcher),
    fork(createCourseWatcher),
    fork(editCourseWatcher),
    fork(deleteCourseWatcher),
    fork(reactivateCourseWatcher),
  ]);
}
Example #11
Source File: sagas.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
function * handleFetchBalance (action) {
  yield put(globalActions.setFetchStatus(true))
  try {
    const { address } = action.payload
    const balance = yield call(api.blockchain.getBalance, { address })
    yield all([
      put(balanceActions.fetchBalanceSuccess({ address, balance })),
      put(globalActions.setFetchStatus(false)),
    ])
  } catch (err) {
    console.error(err)
    yield all([
      put(globalActions.setFetchStatus(false)),
      put(globalActions.setError(new Error('Failed to get wallet balance'))),
    ])
  }
}
Example #12
Source File: actions.js    From what-front with MIT License 6 votes vote down vote up
export function* exportWatcher() {
  yield all([
    fork(exportStudentsClassbookWatcher),
    fork(exportStudentClassbookWatcher),
    fork(exportStudentsResultsWatcher),
    fork(exportStudentResultsWatcher),
    fork(exportStudentGroupResultsWatcher),
  ]);
}
Example #13
Source File: sagas.js    From gobench with Apache License 2.0 6 votes vote down vote up
export default function * rootSaga () {
  yield all([
    takeEvery(actions.LOGIN, LOGIN),
    takeEvery(actions.REGISTER, REGISTER),
    takeEvery(actions.LOAD_CURRENT_ACCOUNT, LOAD_CURRENT_ACCOUNT),
    takeEvery(actions.LOGOUT, LOGOUT),
    LOAD_CURRENT_ACCOUNT() // run once on app load to check user auth
  ])
}
Example #14
Source File: sagas.js    From frontend-app-authn with GNU Affero General Public License v3.0 6 votes vote down vote up
export default function* rootSaga() {
  yield all([
    loginSaga(),
    registrationSaga(),
    commonComponentsSaga(),
    forgotPasswordSaga(),
    resetPasswordSaga(),
    welcomePageSaga(),
  ]);
}
Example #15
Source File: actions.js    From what-front with MIT License 6 votes vote down vote up
export function* lessonsWatcher() {
  yield all([
    fork(fetchLessonsWatcher),
    fork(fetchLessonsByStudentIdWatcher),
    fork(fetchLessonByIdWatcher),
    fork(addLessonWatcher),
    fork(editLessonWatcher),
  ]);
}
Example #16
Source File: movie-details.sagas.js    From movies with MIT License 6 votes vote down vote up
// watchers
export default function* watchMovieDetails() {
  yield all([
    takeEvery(actionKeys.MOVIE_DETAILS, getDetailsSaga),
    takeEvery(actionKeys.MOVIE_CREDITS, getCreditsSaga),
    takeEvery(actionKeys.MOVIE_VIDEOS, getVideosSaga),
    takeEvery(actionKeys.MOVIE_IMAGES, getImagesSaga),
    takeEvery(actionKeys.MOVIE_RECOMMS, getRecommsSaga),
    takeEvery(actionKeys.MOVIE_RESET_ALL, resetMovieDetailsSaga)
  ]);
}
Example #17
Source File: index.js    From gDoctor with MIT License 6 votes vote down vote up
/* ------------- Connect Types To Sagas ------------- */

export default function * root () {
  yield all([
    // some sagas only receive an action
    takeLatest(StartupTypes.STARTUP, startup),

    // some sagas receive extra parameters in addition to an action
    takeLatest(GithubTypes.USER_REQUEST, getUserAvatar, api)
  ])
}
Example #18
Source File: sagas.js    From real-frontend with GNU General Public License v3.0 6 votes vote down vote up
export default function* rootSaga(persistor) {
  yield all([]
    .concat(auth(persistor))
    .concat(camera())
    .concat(theme())
    .concat(posts())
    .concat(users())
    .concat(layout())
    .concat(translation())
    .concat(cache())
  )
}
Example #19
Source File: index.js    From Alfredo-Mobile with MIT License 6 votes vote down vote up
/* ------------- Connect Types To Sagas ------------- */

export default function * root () {
  yield all([
    // some sagas only receive an action
    takeLatest(StartupTypes.STARTUP, startup, api),

    takeLatest(ProductsTypes.GET_PRODUCTS_REQUEST, getProducts, api),
    takeLatest(ProductsTypes.MORE_PRODUCTS_REQUEST, moreProducts, api),
    takeLatest(ProductsTypes.GET_DETAIL_REQUEST, getDetail, api),

    takeLatest(CategoryTypes.GET_CATEGORY_REQUEST, getCategory, api),
    takeLatest(CategoryTypes.SHOW_CATEGORY_REQUEST, showCategory, api),

    takeLatest(AuthTypes.DO_LOGIN_REQUEST, doLogin, api),
    takeLatest(AuthTypes.DO_REGISTER_REQUEST, doRegister, api),
    takeLatest(AuthTypes.DO_LOGOUT_REQUEST, doLogout, api),

    takeLatest(SessionTypes.GET_PROFILE_REQUEST, getProfile, api),

    takeLatest(InvoiceTypes.GET_INVOICE_REQUEST, getInvoice, api),
    takeLatest(InvoiceTypes.MORE_INVOICE_REQUEST, moreInvoice, api),
    takeLatest(InvoiceTypes.SHOW_INVOICE_REQUEST, showInvoice, api),

    takeLatest(OrderTypes.MAKE_ORDER_REQUEST, makeOrder, api),

    takeLatest(ConfirmPaymentTypes.CONFIRM_PAYMENT_REQUEST, confirmPayment, api)
  ])
}
Example #20
Source File: index.js    From haven with MIT License 6 votes vote down vote up
export default function* mainSaga() {
  yield all([
    SocketSaga(),
    ProductSaga(),
    SearchSaga(),
    AppstateSaga(),
    ProfileSaga(),
    ModeratorsSaga(),
    FollowSaga(),
    CreateListingSaga(),
    NotificationsSaga(),
    SettingsSaga(),
    ModerationSettingsSaga(),
    ChatSaga(),
    OrderSaga(),
    FeedSaga(),
    ExchangeRateSaga(),
    WalletSaga(),
    ListingsSaga(),
    FeaturedSaga(),
    PromoSaga(),
    StoreListingsSaga(),
    ConfigurationSaga(),
    RatingsSaga(),
    StreamSaga(),
  ]);
}
Example #21
Source File: effect.js    From lrc-staking-dapp with MIT License 6 votes vote down vote up
export default function* () {
  yield all([
    takeLatest(STAKING_GET_STAKE_LIST, fetchEventStackedList),
    takeLatest(STAKING_GET_TOTAL_STAKE, fetchTotalStake),
    takeLatest(STAKING_GET_YOUR_STAKE, fetchYourStake),
    takeLatest(STAKING_DO_STAKE, doStake),
    takeLatest(STAKING_DO_CLAIM, doClaim),
    takeLatest(STAKING_DO_WITHDRAW, doWithdraw),
  ]);
}
Example #22
Source File: user.sagas.js    From CodeSignal-Practice_Solutions with MIT License 6 votes vote down vote up
export function* userSagas() {
  yield all([
    call(onGoogleSignInStart),
    call(onEmailSignInStart),
    call(onCheckUserSession),
    call(onSignOutStart),
    call(onSignUpStart),
    call(onSignUpSuccess)
  ]);
}
Example #23
Source File: index.js    From jc-calendar with MIT License 6 votes vote down vote up
/**
 * Spawns given sagas, restarting them if they throw any uncaught error.
 * @param  {...GeneratorFunction} sagas The sagas to spawn and keep alive
 */
function* keepAlive(...sagas) {
  yield all(
    sagas.map((saga) =>
      spawn(function* () {
        while (true) {
          try {
            // Start the worker saga
            yield call(saga);
            // If it finishes, exit
            break;
          } catch (e) {
            // If an error happens it will be logged
            // and the loop will restart the saga
            console.groupCollapsed(
              `%cSaga ${saga.name} crashed and will be restarted...`,
              `
                font-size: 600;
                color: #DC2626;
                background-color: #FECACA;
                padding: 0.125rem 0.25rem;
                border-radius: 0.125rem;
              `
            );
            console.error(e);
            console.groupEnd();
          }
        }
      })
    )
  );
}
Example #24
Source File: index.js    From agenda with MIT License 6 votes vote down vote up
export default function* root() {
    yield all([
        takeEvery(FETCH_ASSIGNMENTS_REQUESTED, fetchAssignments),
        takeEvery(SUBMIT_ASSIGNMENT_DATA_REQUESTED, submitAssignmentData),
        takeEvery(FETCH_ASSIGNMENT_REQUESTED, fetchAssignment),
        takeEvery(FETCH_CONTACTS_REQUESTED, fetchContacts),
        takeEvery(SUBMIT_CONTACT_DATA_REQUESTED, submitContactData),
        takeEvery(FETCH_CONTACT_REQUESTED, fetchContact),
        takeEvery(FETCH_DEPARTMENTS_REQUESTED, fetchDepartments),
        takeEvery(SUBMIT_DEPARTMENT_DATA_REQUESTED, submitDepartmentData),
        takeEvery(FETCH_DEPARTMENT_REQUESTED, fetchDepartment),
        takeEvery(DELETE_ASSIGNMENT_REQUESTED, deleteAssignment)
    ]);
}
Example #25
Source File: AuthSagas.js    From Alfredo-Mobile with MIT License 6 votes vote down vote up
export function * doLogout(api, action) {
  api.api.setHeaders(api.headers)

  yield all([
    yield put(SessionsActions.clearSession()),
    yield put(AuthActions.doLogoutSuccess("Logout Success"))
  ])

  Toast.show("Logout Successfully!", Toast.SHORT)
}
Example #26
Source File: saga.js    From gedge-platform with Apache License 2.0 6 votes vote down vote up
function* LayoutSaga() {
	yield all([
		fork(watchChangeLayoutType),
		fork(watchChangeLayoutWidth),
		fork(watchChangeLeftSidebarTheme),
		fork(watchChangeLeftSidebarType),
		fork(watchToggleRightSidebar),
		fork(watchShowRightSidebar),
		fork(watchHideRightSidebar),
		fork(watchChangeTopbarTheme)
	]);
}
Example #27
Source File: AuthSagas.js    From Alfredo-Mobile with MIT License 6 votes vote down vote up
export function * doLogin(api, action) {
  const { data } = action
  const response = yield call(api.authLogin, data)

  if(response.ok) {
    api.api.setHeaders({
      "X-AUTH-TOKEN": `Bearer ${response.data.data.token}`
    })

    yield all([
      yield put(AuthActions.doLoginSuccess(response.data.data)),
      yield put(SessionsActions.saveSession(response.data.data)),
      yield put(SessionsActions.getProfileRequest())
    ])

    Toast.show("Login Successfully!", Toast.SHORT)

    if (data.event === null) {
      NavigationServices.goBack()
    } else {
      NavigationServices.goBack()
      data.event()
    }
  } else {
    yield put(AuthActions.doLoginFailure(response))
    Toast.show(response?.data?.data?.message ?? "Internal Server Error", Toast.SHORT)
  }
}
Example #28
Source File: sagas.js    From gedge-platform with Apache License 2.0 6 votes vote down vote up
export default function* rootSaga() {
    yield all([
        
        //public
        accountSaga(),
        loginSaga(),
        forgetSaga(),
        LayoutSaga()
    ])
}
Example #29
Source File: sagas.js    From gobench with Apache License 2.0 6 votes vote down vote up
export default function * rootSaga () {
  yield all([
    takeEvery(actions.LIST, LIST),
    takeEvery(actions.DETAIL, DETAIL),
    takeEvery(actions.CREATE, CREATE),
    takeEvery(actions.UPDATE, UPDATE),
    takeEvery(actions.DELETE, DELETE),
    takeEvery(actions.LOG, LOG),
    takeEvery(actions.SYSLOG, SYSLOG),
    takeEvery(actions.TAGS, TAGS),
    takeEvery(actions.TAG_ADD, TAG_ADD),
    takeEvery(actions.TAG_REMOVE, TAG_REMOVE),

    takeEvery(actions.CLONE, CLONE),
    takeEvery(actions.CANCEL, CANCEL),
    takeEvery(actions.GROUPS, GROUPS),
    takeEvery(actions.GRAPHS, GRAPHS),
    takeEvery(actions.GRAPH_METRICS, GRAPH_METRICS),
    // takeEvery(actions.COUNTERS, COUNTERS),
    takeEvery(actions.HISTOGRAMS, HISTOGRAMS),
    takeEvery(actions.GAUGES, GAUGES),
    takeEvery(actions.METRICS, METRICS),
    takeEvery(actions.METRIC_DATA, METRIC_DATA),
    takeEvery(actions.GRAPH_METRIC_DATA, GRAPH_METRIC_DATA),
    takeEvery(actions.METRIC_DATA_POLLING, METRIC_DATA_POLLING)
  ])
}