How to use the redux-saga/effects.put 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 platformio / platformio-atom-ide / lib / account / sagas.js View on Github external
return;
      }
      yield put(updateFlagValue(selectors.IS_AUTH_REQUEST_IN_PROGRESS_KEY, true));
      yield put(updateInputValue(selectors.LAST_USED_USERNAME_KEY, username));
      yield call(runAccountCommand, 'login', {
        extraArgs: ['--username', username, '--password', password],
      });
      yield put(updateFlagValue(selectors.IS_LOGGED_IN_KEY, true));
      yield put(actions.authFormSuccess());
      yield put(deleteError(LOGIN_FORM));
      yield put(updateFlagValue(selectors.IS_AUTH_REQUEST_IN_PROGRESS_KEY, false));
      atom.notifications.addSuccess('You have logged in successfully');

      // Immediately request info update, which will in turn update the
      // Information  page in if it's opened.
      yield put(actions.accountInfoUpdateRequest());
    } catch (error) {
      yield put(updateError(LOGIN_FORM, error.message));
      console.error(error);
    } finally {
      yield put(updateFlagValue(selectors.IS_AUTH_REQUEST_IN_PROGRESS_KEY, false));
    }
  });
}
github keybase / client / shared / util / saga.tsx View on Github external
action = undefined
      if (toPut) {
        const outActions: Array = isArray(toPut) ? toPut : [toPut]
        for (var out of outActions) {
          if (out) {
            yield Effects.put(out)
          }
        }
      }
      if (sl.isTagged) {
        sl.info('-> ok')
      }
    } catch (error) {
      sl.warn(error.message)
      // Convert to global error so we don't kill the takeEvery loop
      yield Effects.put(
        ConfigGen.createGlobalError({
          globalError: convertToError(error),
        })
      )
    } finally {
      if (yield Effects.cancelled()) {
        sl.info('chainAction cancelled')
      }
    }
  })
}
github deepfunc / react-test-demo / src / client / store / sagas / bizToolbar.js View on Github external
export function* onUpdateKeywords() {
  yield put(bizTableActions.reloadBizTableData());
}
github bandprotocol / band / app / src / sagas / transaction.js View on Github external
function* sendTransaction({ transaction, title, type }) {
  const timestamp = new Date().getTime()
  try {
    yield put(addPendingTx(timestamp, title, type))
    const txHash = yield transaction.sendFeeless()
    const network = yield select(currentNetworkSelector)
    const userAddress = yield select(currentUserSelector)
    yield put(addTx(txHash, title, type, network, userAddress))
    yield put(dumpTxs())
  } catch (error) {
    if (error.code === -32010) {
      const currentUser = yield select(currentUserSelector)
      const currentNetwork = yield select(currentNetworkSelector)
      if (currentNetwork === 'mainnet') {
        window.confirm(`Insufficient ETH to pay for gas fee. Please Buy eth`)
      } else {
        if (
          window.confirm(
            `Insufficient ETH to pay for gas fee. Please request free ${currentNetwork} testnet ETH and send it to ${currentUser} ?`,
          )
        ) {
          switch (currentNetwork) {
            case 'kovan':
              window.open('https://gitter.im/kovan-testnet/faucet')
              break
github opennode / waldur-homeport / src / ansible / jupyter-hub-management / effects.ts View on Github external
function* handleInitializeJupyterHubManagementCreate() {
  try {
    const pythonManagementResponse = yield call(findPythonManagementsWithInstance);
    yield put(saveAvailablePythonManagements(pythonManagementResponse));

    yield put(initialize(JUPYTER_HUB_MANAGEMENT_CREATE_FORM_NAME, new JupyterHubManagementFormData()));

    yield put(jupyterHubManagementLoaded());
    yield put(initializeJupyterHubManagementCreate.success());
  } catch (error) {
    yield put(jupyterHubManagementErred());
    yield put(initializeJupyterHubManagementCreate.failure());
  }
}
github goblindegook / dictionary-react-redux-typescript / src / sagas / definition.ts View on Github external
export function* definitionWorker(action: Action): IterableIterator {
  const id = action.payload

  try {
    const entries: IEntry[] = yield call(define, id)
    yield put(definitionDone(entries))
  } catch (error) {
    yield put(definitionError(error))
  }
}
github antoinejaussoin / retro-board / app / modules / board / session / sagas.js View on Github external
export function* onCreateSession(action) {
  const sessionId = yield call(shortid.generate);
  const sessionName = action.payload || null;
  const user = yield select(getCurrentUser);
  yield put(
    createSessionSuccess({
      sessionId,
    }),
  );
  yield call(storeSessionToLocalStorage, user, sessionId);
  yield put(renameSession(sessionName));
  yield put(
    joinSession({
      sessionId,
      user,
    }),
  );
  yield put(receiveClientList([user]));
  yield put(push(`/session/${sessionId}`));
}
github LeadcoinNetwork / Web-App-Project / frontend / src / sagas / editLead.js View on Github external
export default function* editLead(api) {
  while (true) {
    const action = yield take(types.EDIT_LEAD_SUBMIT_FORM)
    let { original_copy, values, agree_to_terms } = yield select(
      state => state.editLead,
    )
    const prepData = prepareLeadDataForSend(values)
    const lead = Object.assign(original_copy, prepData, {
      agree_to_terms,
    })

    yield put(actions.editLead.editLeadLoadingStart())
    let res = yield api.leads.editLeadsEditByForm({ lead })
    yield put(actions.editLead.editLeadLoadingEnd())
    if (res.error) {
      const errors = res.error
      for (let error in errors) {
        yield put(actions.editLead.editLeadAddError(error, errors[error]))
      }
    } else {
      yield put(actions.editLead.editLeadSubmitSuccess())
      window.triggerFetch()
      yield put(push("/my-leads"))
    }
  }
}
github sovrin-foundation / connector-app / app / store / config-store.js View on Github external
export function* watchSwitchErrorAlerts(): any {
  while (true) {
    for (let i = 0; i < 4; i++) {
      yield take(SWITCH_ERROR_ALERTS)
    }

    const switchValue = yield select(getErrorAlertsSwitchValue)
    yield put(toggleErrorAlerts(!switchValue))
  }
}