How to use the redux-saga/effects.call 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 freedomexio / rocketx-condenser / src / app / redux / UserSaga.js View on Github external
takeLatest(userActions.ACCEPT_TERMS, function*() {
        try {
            yield call(acceptTos);
        } catch (e) {
            // TODO: log error to server, conveyor is unavailable
        }
    }),
    takeLatest(userActions.VOTING_POWER_LOOKUP, lookupVotingPower),
github textileio / advanced-react-native-boilerplate / src / Sagas / SubSagas / Game.ts View on Github external
// Only a block author can make themself it, actor === gameEvent.target
      if (started === true && gameEvent.event === 'tag' && gameEvent.source === tagged.address && actor === gameEvent.target) {
        const newlyTagged: IContact = yield call([Textile.contacts, 'get'], gameEvent.target)
        yield put(MainActions.newTag(tagged, newlyTagged, file.block, file.date.seconds as number))
        tagged = newlyTagged
      }
    }

    if (started) {
      yield put(MainActions.startGameSuccess(startTime))
    }

    yield put(MainActions.setCurrentIt(tagged))

    yield call(refreshGameContacts, thread)
    yield call(updateMessages, thread)

  } catch (error) {
    yield put(MainActions.pushNewMessage(
      {type: 'text', message: `Uh oh: ${error.message}`}
    ))
  }
}
github decentraland / explorer / packages / shared / passports / sagas.ts View on Github external
export function* handleFetchProfile(action: PassportRequestAction): any {
  const userId = action.payload.userId
  try {
    const serverUrl = yield select(getProfileDownloadServer)
    const accessToken = yield select(getAccessToken)
    const profile = yield call(profileServerRequest, serverUrl, userId, accessToken)
    const currentId = yield select(getCurrentUserId)
    if (currentId === userId) {
      profile.email = yield select(getEmail)
    }
    if (profile.ethAddress) {
      yield put(inventoryRequest(userId, profile.ethAddress))
      const inventoryResult = yield race({
        success: take(isActionFor(INVENTORY_SUCCESS, userId)),
        failure: take(isActionFor(INVENTORY_FAILURE, userId))
      })
      if (inventoryResult.failure) {
        defaultLogger.error(`Unable to fetch inventory for ${userId}:`, inventoryResult.failure)
      } else {
        profile.inventory = (inventoryResult.success as InventorySuccess).payload.inventory.map(dropIndexFromExclusives)
      }
    } else {
github opennode / waldur-homeport / src / project / effects.ts View on Github external
export function* handleCreateProject(action) {
  const successMessage = translate('Project has been created.');
  const errorMessage = translate('Project could not be created.');

  try {
    const customer = yield select(getCustomer);
    const response = yield call(api.createProject, {...action.payload, customer});
    const project = response.data;
    yield call(api.gotoProjectDetails, project);
    yield call(api.refreshProjectList, project);
    yield put(createProject.success());
    yield put(showSuccess(successMessage));
  } catch (error) {
    const formError = new SubmissionError({
      _error: errorMessage,
      name: error.data.name,
    });

    yield put(createProject.failure(formError));
  }
}
github web-pal / chronos-timetracker / app / sagas / worklogs.js View on Github external
export function* uploadWorklog(options: any): Generator<*, *, *> {
  try {
    yield call(
      infoLog,
      'started uploading worklog with options:',
      options,
    );
    /*
    const {
      issueId,
      comment,
      timeSpentInSeconds,
      screenshotsPeriod,
      worklogType,
      screenshots,
      activity,
      keepedIdles,
    } = options;
    */
github secret-tech / frontend-moon-wallet / src / sagas / app / themeSaga.js View on Github external
function* checkThemeStateIterator() {
  const theme = yield call(getThemeFromStorage);
  if (theme) {
    yield put(setThemeState(theme));
  } else {
    yield put(setThemeState(''));
  }
}
github pathephone / pathephone-desktop / src / renderer / sagas / startApp / startServices / startAlbumsSharingService / handleShareFilesSelect / getAlbumCandidatesFromItems.js View on Github external
function* getAlbumCandidatesFromItems(apis, selectedItems) {
  const { splitFoldersAndFiles } = apis;
  const { folders, files } = yield call(splitFoldersAndFiles, selectedItems);
  const [candidateFromFiles, candidatesFromFolders] = yield all([
    call(getCandidateFromFiles, apis, files),
    call(getAlbumCandidatesFromFolders, apis, folders),
  ]);
  const candidates = [];
  if (candidateFromFiles) {
    candidates.push(candidateFromFiles);
  }
  if (candidatesFromFolders) {
    candidates.push(...candidatesFromFolders);
  }
  return candidates;
}
github mojisrc / fashop-admin / src / sagas / deliver / express.js View on Github external
function* list({ params }) {
    yield put({
        type: types.express.START_GET_EXPRESS_LIST
    })
    const e = yield call(Fetch.fetch, { api: ExpressApi.list, params })
    if (e.code === 0) {
        yield put(saveList({ result: e.result, params }))
    } else {
        message.warning(e.msg)
    }
}