How to use the redux-saga/effects.cancel 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 redux-saga / redux-saga / packages / core / __tests__ / typescript / effects.ts View on Github external
function* testCancel(): SagaIterator {
  yield cancel()

  // typings:expect-error
  yield cancel(undefined)
  // typings:expect-error
  yield cancel({})

  yield cancel(task)
  // typings:expect-error
  yield cancel(task, task)
  yield cancel([task, task])
  yield cancel([task, task, task])

  const tasks: Task[] = []

  yield cancel(tasks)
github samtecspg / articulate / ui / app / containers / AgentDetailPage / sagas.js View on Github external
export function* loadWebhook() {
  const watcher = yield takeLatest(LOAD_WEBHOOK, getWebhook);

  // Suspend execution until location changes
  yield take(LOCATION_CHANGE);
  yield cancel(watcher);
}
github fission / fission-ui / app / containers / FunctionCreatePage / sagas.js View on Github external
export function* testFunctionSaga() {
  const watcher = yield takeLatest(TEST_FUNCTION_REQUEST, testFunction);

  // Suspend execution until location changes
  yield take(LOCATION_CHANGE);
  yield cancel(watcher);
}
github WaftTech / WaftEngine / client / app / containers / OrganizationInfoPage / saga.js View on Github external
const token = yield select(makeSelectToken());
  const { ProfileImage, ProfileImage1, ...data } = action.payload;
  // const files = {ProfileImage, ProfileImage1};
  const files = [ProfileImage, ProfileImage1];
  yield fork(
    Api.multipartPost(
      'org',
      actions.addEditSuccess,
      actions.addEditFailure,
      data,
      files,
      token,
    ),
  );
  yield take([LOCATION_CHANGE, types.ADD_EDIT_FAILURE]);
  yield cancel(successWatcher);
}
github WaftTech / WaftEngine / client / app / containers / AdminFaqCategoryManagePage / saga.js View on Github external
function* addEdit() {
  const sucessWatcher = yield fork(redirectOnSuccess);
  const token = yield select(makeSelectToken());
  const data = yield select(makeSelectOne());
  yield fork(
    Api.post(
      `faq/cat`,
      actions.addEditSuccess,
      actions.addEditFailure,
      data,
      token,
    ),
  );
  yield take([LOCATION_CHANGE, types.ADD_EDIT_FAILURE]);
  yield cancel(sucessWatcher);
}
function* deleteCat(action) {
github keybase / client / shared / actions / chat / attachment.js View on Github external
try {
    const channelMap = ((yield call(ChatTypes.localDownloadFileAttachmentLocalRpcChannelMapOld, channelConfig, {param})): any)

    const progressTask = yield Saga.effectOnChannelMap(c => Saga.safeTakeEvery(c, function * ({response}) {
      const {bytesComplete, bytesTotal} = response.param
      yield put(Creators.downloadProgress(conversationIDKey, messageID, loadPreview || isHdPreview, bytesComplete, bytesTotal))
      response.result()
    }), channelMap, 'chat.1.chatUi.chatAttachmentDownloadProgress')

    const start = yield Saga.takeFromChannelMap(channelMap, 'chat.1.chatUi.chatAttachmentDownloadStart')
    start.response.result()

    const done = yield Saga.takeFromChannelMap(channelMap, 'chat.1.chatUi.chatAttachmentDownloadDone')
    done.response.result()

    yield cancel(progressTask)
    Saga.closeChannelMap(channelMap)

    yield put(Creators.attachmentLoaded(conversationIDKey, messageID, filename, loadPreview, isHdPreview))
  } catch (err) {
    yield put(Creators.attachmentLoaded(conversationIDKey, messageID, null, loadPreview, isHdPreview))
  }
}
github strapi / strapi-examples / cheesecakes / plugins / settings-manager / admin / src / containers / HomePage / sagas.js View on Github external
export function* defaultSaga() {
  const loadConfigWatcher = yield fork(takeLatest, CONFIG_FETCH, fetchConfig);
  const loadLanguagesWatcher = yield fork(takeLatest, LANGUAGES_FETCH, fetchLanguages);
  const editConfigWatcher = yield fork(takeLatest, EDIT_SETTINGS, settingsEdit);
  const postLanguageWatcher = yield fork(takeLatest, NEW_LANGUAGE_POST, postLanguage);
  const deleteLanguageWatcher = yield fork(takeLatest, LANGUAGE_DELETE, deleteLanguage);
  const loadDatabasesWatcher = yield fork(takeLatest, DATABASES_FETCH, fetchDatabases);
  const postDatabaseWatcher = yield fork(takeLatest, NEW_DATABASE_POST, postDatabase);
  const deleteDatabaseWatcher = yield fork(takeLatest, DATABASE_DELETE, deleteDatabase);
  const fetchSpecificDatabaseWatcher = yield fork(takeLatest, SPECIFIC_DATABASE_FETCH, fetchSpecificDatabase);
  const editDatabaseWatcher = yield fork(takeLatest, DATABASE_EDIT, editDatabase);

  yield take(LOCATION_CHANGE);
  yield cancel(loadConfigWatcher);
  yield cancel(loadLanguagesWatcher);
  yield cancel(editConfigWatcher);
  yield cancel(postLanguageWatcher);
  yield cancel(deleteLanguageWatcher);
  yield cancel(loadDatabasesWatcher);
  yield cancel(postDatabaseWatcher);
  yield cancel(deleteDatabaseWatcher);
  yield cancel(fetchSpecificDatabaseWatcher);
  yield cancel(editDatabaseWatcher);
}
github strapi / strapi-examples / cheesecakes / plugins / users-permissions / admin / src / containers / HomePage / saga.js View on Github external
export function* defaultSaga() {
  const loadDataWatcher = yield fork(takeLatest, FETCH_DATA, dataFetch);

  yield fork(takeLatest, DELETE_DATA, dataDelete);
  yield fork(takeLatest, SUBMIT, submitData);

  yield take(LOCATION_CHANGE);
  yield cancel(loadDataWatcher);
}
github strapi / strapi / packages / strapi-plugin-settings-manager / admin / src / containers / Home / sagas.js View on Github external
export function* defaultSaga() {
  const loadConfigWatcher = yield fork(takeLatest, CONFIG_FETCH, fetchConfig);
  const loadLanguagesWatcher = yield fork(takeLatest, LANGUAGES_FETCH, fetchLanguages);
  const editConfigWatcher = yield fork(takeLatest, EDIT_SETTINGS, settingsEdit);
  const postLanguageWatcher = yield fork(takeLatest, NEW_LANGUAGE_POST, postLanguage);
  const deleteLanguageWatcher = yield fork(takeLatest, LANGUAGE_DELETE, deleteLanguage);
  const loadDatabasesWatcher = yield fork(takeLatest, DATABASES_FETCH, fetchDatabases);

  yield take(LOCATION_CHANGE);
  yield cancel(loadConfigWatcher);
  yield cancel(loadLanguagesWatcher);
  yield cancel(editConfigWatcher);
  yield cancel(postLanguageWatcher);
  yield cancel(deleteLanguageWatcher);
  yield cancel(loadDatabasesWatcher);

}
github WaftTech / WaftEngine / client-v2 / app / containers / SignupUserPage / saga.js View on Github external
const name = yield select(makeSelectName());
  const gender = yield select(makeSelectGender());
  const data = { email, password, password2: password, name, gender };
  const errors = validate(data);
  if (errors.isValid) {
    const successWatcher = yield fork(redirectOnSuccess, action.redirect);
    yield fork(
      Api.post(
        'user/register',
        actions.signupSuccess,
        actions.signupFailure,
        data,
      ),
    );
    yield take([LOCATION_CHANGE, types.SIGNUP_FAILURE]);
    yield cancel(successWatcher);
  } else {
    yield put(actions.setStoreValue({ key: 'errors', value: errors.errors }));
  }
}