How to use the redux-saga/effects.select function in redux-saga

To help you get started, we’ve selected a few redux-saga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rchain-community / rchain.cloud / frontend / src / saga / file_operations_saga.js View on Github external
export function* renameFile(action) {
  // Redux state 'files'
  let state = yield select(state => state.files)
  let newFileName = yield call(preprocessFileName, action.payload.newName)
  let isFileNameValid = yield call(validateFileName, action.payload.newName)
  if (!isFileNameValid) {
    // Invalid filename
    console.log(
      '%cFile renaming failed: New filename ' +
      '(' + action.payload.file.module + ')' +
      ' is invalid', 'color: red'
    )
    yield put(fileNameInvalid(action.payload.file.module))
    return
  }

  let oldFile = Object.assign({}, action.payload.file)
  // Extract Parent's Path
  let parentPath = yield call(extractParentsPath, action.payload.file)
github web-pal / chronos-timetracker / app / sagas / profile.js View on Github external
export function* loginFlow(): Generator<*, void, *> {
  while (true) {
    try {
      const { payload }: LoginRequestAction = yield take(types.LOGIN_REQUEST);
      yield call(infoLog, 'loginFlow started', payload);
      const host = yield select(getHost);
      if (!payload.host || (!(payload.host instanceof URL) && host instanceof URL)) {
        // $FlowFixMe
        payload.host = host;
      }
      yield call(clearLoginError);
      yield put(profileActions.setLoginFetching(true));
      const chronosBackendLoginSuccess: boolean = yield call(chronosBackendLogin, payload);
      if (chronosBackendLoginSuccess) {
        const jiraLoginSuccess: boolean = yield call(jiraLogin, payload);
        if (jiraLoginSuccess) {
          yield call(setToStorage, 'jira_credentials', { username: payload.username, password: '', host: payload.host.origin });
          yield call((): void => { ipcRenderer.sendSync('store-credentials', payload); });
          yield call(afterLogin);
        }
      }
      yield put(profileActions.setLoginFetching(false));
github MyCryptoHQ / MyCrypto / common / features / config / sagas.spec.ts View on Github external
it('should select getStaticNodeFromId', () => {
    expect(gen.next(true).value).toEqual(select(selectors.getStaticNodeFromId, payload));
  });
github Ethbet / ethbet / alpha / src / sagas / balanceSaga.js View on Github external
function* loadBalances(data) {
  yield put(balanceActions.fetchLoadBalance.request());
  try {
    const web3 = yield select(state => state.web3Store.get("web3"));
    const balances = yield call(balanceService.loadBalances, web3);
    yield put(balanceActions.fetchLoadBalance.success(balances));
  } catch (error) {
    yield put(balanceActions.fetchLoadBalance.failure({error}));
  }
}
github ayastreb / money-tracker / src / sagas / settings.js View on Github external
export function* updateCurrencySaga() {
  const base = yield select(getBaseCurrency);
  const secondary = yield select(getSecondaryCurrency);
  const used = yield select(getAccountsCurrencyList);
  try {
    const exchangeRate = yield call(
      fetchExchangeRates,
      base,
      union(secondary, used)
    );
    yield put(updateExchangeRateSuccess(exchangeRate));
    yield call(SettingsStorage.save, {
      currency: { base, secondary },
      exchangeRate
    });
  } catch (error) {
    yield put(updateExchangeRateFailure(error));
  }
}
github uport-project / uport-mobile / lib / sagas / keychain.js View on Github external
export function * canSignFor (address) {
  const settings = yield select(networkSettingsForAddress, address)
  if (yield select(isHD, address)) {
    const idIndex = yield select(hdIdentityIndex, address)
    const actIndex = yield select(hdAccountIndex, address)
    const r = yield call(addressFor, idIndex, actIndex)
    return r.address === (settings.deviceAddress || settings.hexaddress)
  } else {
    const addresses = yield call(RNUportSigner.allAddresses)
    return addresses.includes(settings.deviceAddress || settings.hexaddress)
  }
}
github strapi / strapi-examples / nuxt-strapi-deliveroo-clone-tutorial / server / plugins / content-manager / admin / src / containers / EditPage / saga.js View on Github external
function* deleteData() {
  try {
    const currentModelName = yield select(makeSelectModelName());
    const record = yield select(makeSelectRecord());
    const id = record.id || record._id;
    const source = yield select(makeSelectSource());
    const requestUrl = `/content-manager/explorer/${currentModelName}/${id}`;

    yield call(request, requestUrl, { method: 'DELETE', params: { source } });
    strapi.notification.success('content-manager.success.record.delete');
    yield new Promise(resolve => {
      setTimeout(() => {
        resolve();
      }, 300);
    });
    yield put(submitSuccess());
  } catch(err) {
    strapi.notification.error('content-manager.error.record.delete');
  }
}
github WaftTech / WaftEngine / client / app / containers / Admin / Slider / saga.js View on Github external
function* loadMedia(action) {
  const token = yield select(makeSelectToken());
  let query = '';
  if (action.payload) {
    Object.keys(action.payload).map(each => {
      query = `${query}&${each}=${action.payload[each]}`;
      return null;
    });
  }
  yield call(
    Api.get(
      `media?${query}`,
      actions.loadMediaSuccess,
      actions.loadMediaFailure,
      token,
    ),
  );
}