redux-saga/effects#takeLatest TypeScript Examples

The following examples show how to use redux-saga/effects#takeLatest. 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: updater.ts    From marina with MIT License 6 votes vote down vote up
// starts an update for all accounts after each AUTHENTICATION_SUCCESS action
// only updates the accounts for the current network
export function* updateAfterEachLoginAction(): SagaGenerator<void, void> {
  yield takeLatest(AUTHENTICATION_SUCCESS, function* () {
    // enable periodic updaters
    periodicUpdater();
    periodicTaxiUpdater();
    // update taxi assets, utxos and txs
    const accountsID = yield* selectAllAccountsIDsSaga();
    const network = yield* selectNetworkSaga();
    for (const ID of accountsID) {
      yield put(updateTaxiAssets());
      yield put(updateTaskAction(ID, network));
    }
  });
}
Example #2
Source File: index.ts    From camus with GNU Affero General Public License v3.0 6 votes vote down vote up
export default function* rootSaga() {
    yield takeLatest(setUsername.type, doSetUsername);
    yield takeEvery(sendChatMessage.type, doSendChatMessage);
    yield takeLatest(setLocalAudio.type, doSetLocalAudio);
    yield takeLatest(setLocalVideo.type, doSetLocalVideo);
    yield takeLatest(setResolution.type, doSetResolution);
    yield takeLatest(disableRemoteVideo.type, doDisableRemoteVideo);
    yield takeLatest(enableRemoteVideo.type, doEnableRemoteVideo);
    yield takeEvery(addIceServer.type, doSetIceServers);
    yield takeEvery(removeIceServer.type, doSetIceServers);
    yield takeEvery(updateIceServer.type, doSetIceServers);
}
Example #3
Source File: sagas.ts    From firebase-tools-ui with Apache License 2.0 6 votes vote down vote up
export function* initAuth({ payload }: ActionType<typeof updateAuthConfig>) {
  if (!payload) {
    return;
  }
  yield setContext({
    [AUTH_API_CONTEXT]: new AuthApi(
      payload.auth.hostAndPort,
      payload.projectId
    ),
  });
  yield all([
    takeLatest(getType(authFetchUsersRequest), fetchAuthUsers),
    takeLatest(getType(createUserRequest), createUser),
    takeLatest(getType(nukeUsersRequest), nukeUsers),
    takeLatest(getType(deleteUserRequest), deleteUser),
    takeLatest(getType(updateUserRequest), updateUser),
    takeLatest(getType(setUserDisabledRequest), setUserDisabled),
    takeLatest(
      getType(setAllowDuplicateEmailsRequest),
      setAllowDuplicateEmails
    ),
    takeLatest(
      getType(getAllowDuplicateEmailsRequest),
      getAllowDuplicateEmails
    ),
    put(authFetchUsersRequest()),
    put(getAllowDuplicateEmailsRequest()),
  ]);
}
Example #4
Source File: rootSaga.ts    From rhub-app with MIT License 6 votes vote down vote up
export default function* rootSaga(): Generator {
  return yield all([
    takeLatest(CowsayTypes.LOAD_REQUEST, load),
    ...userSagas,
    ...labPolicySagas,
    ...labProductSagas,
    ...clusterSagas,
    ...labRegionSagas,
    ...labLocationSagas,
  ]);
}
Example #5
Source File: index.ts    From foodie with MIT License 6 votes vote down vote up
function* rootSaga() {
    yield takeLatest([
        LOGIN_START,
        LOGOUT_START,
        REGISTER_START,
        CHECK_SESSION,
    ], authSaga);

    yield takeLatest([
        GET_FEED_START,
        CREATE_POST_START
    ], newsFeedSaga);

    yield takeLatest([
        GET_USER_START
    ], profileSaga)
}
Example #6
Source File: sagas.ts    From rhub-app with MIT License 6 votes vote down vote up
clusterSagas = [
  takeLatest(ClusterTypes.LOAD_REQUEST, load),
  takeLatest(ClusterTypes.LOAD_HOST_REQUEST, loadHost),
  takeLatest(ClusterTypes.LOAD_STDOUT_REQUEST, loadStdout),
  takeLatest(ClusterTypes.LOAD_EVENTS_REQUEST, loadClusterEvents),
  takeLatest(ClusterTypes.UPDATE_REQUEST, update),
  takeLatest(ClusterTypes.DELETE_REQUEST, remove),
  takeLatest(ClusterTypes.CREATE_REQUEST, create),
  takeLatest(ClusterTypes.REBOOT_HOST_REQUEST, rebootHost),
]
Example #7
Source File: saga.ts    From react-boilerplate-cra-template with MIT License 6 votes vote down vote up
/**
 * Root saga manages watcher lifecycle
 */
export function* githubRepoFormSaga() {
  // Watches for loadRepos actions and calls getRepos when one comes in.
  // By using `takeLatest` only the result of the latest API call is applied.
  // It returns task descriptor (just like fork) so we can continue execution
  // It will be cancelled automatically on component unmount
  yield takeLatest(actions.loadRepos.type, getRepos);
}
Example #8
Source File: saga.test.ts    From react-boilerplate-cra-template with MIT License 6 votes vote down vote up
describe('githubRepoFormSaga Saga', () => {
  const githubRepoFormIterator = githubRepoFormSaga();
  it('should start task to watch for loadRepos action', () => {
    const takeLatestDescriptor = githubRepoFormIterator.next().value;
    expect(takeLatestDescriptor).toEqual(
      takeLatest(slice.githubRepoFormActions.loadRepos.type, getRepos),
    );
  });
});
Example #9
Source File: sagas.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
function* watchPushCustomType() {
  yield takeLatest(
    getType(pushCustomTypeCreator.request),
    withLoader(pushCustomTypeSaga, LoadingKeysEnum.PUSH_CUSTOM_TYPE)
  );
}
Example #10
Source File: sagas.ts    From rhub-app with MIT License 5 votes vote down vote up
userSagas = [
  takeLatest(UserTypes.LOAD_REQUEST, load),
  takeLatest(UserTypes.TOKEN_UPDATE, tokenUpdate),
  takeLatest(UserTypes.LOGIN_REQUEST, login),
]
Example #11
Source File: sagas.ts    From rhub-app with MIT License 5 votes vote down vote up
labRegionSagas = [
  takeLatest(LabRegionTypes.LOAD_REQUEST, load),
  takeLatest(LabRegionTypes.CREATE_REQUEST, create),
  takeLatest(LabRegionTypes.UPDATE_REQUEST, update),
  takeLatest(LabRegionTypes.DELETE_REQUEST, remove),
  takeLatest(LabRegionTypes.LOAD_PRODUCT_REGIONS_REQUEST, load_product_regions),
  takeLatest(LabRegionTypes.LOAD_USAGE_REQUEST, load_region_usage),
]
Example #12
Source File: sagas.ts    From rhub-app with MIT License 5 votes vote down vote up
labProductSagas = [
  takeLatest(LabProductTypes.LOAD_REQUEST, load),
  takeLatest(LabProductTypes.CREATE_REQUEST, create),
  takeLatest(LabProductTypes.UPDATE_REQUEST, update),
  takeLatest(LabProductTypes.DELETE_REQUEST, remove),
]
Example #13
Source File: sagas.ts    From rhub-app with MIT License 5 votes vote down vote up
labPolicySagas = [
  takeLatest(LabPolicyTypes.LOAD_REQUEST, load),
  takeLatest(LabPolicyTypes.CREATE_REQUEST, create),
  takeLatest(LabPolicyTypes.UPDATE_REQUEST, update),
  takeLatest(LabPolicyTypes.DELETE_REQUEST, remove),
]
Example #14
Source File: sagas.ts    From rhub-app with MIT License 5 votes vote down vote up
labProductSagas = [
  takeLatest(LabLocationTypes.LOAD_REQUEST, load),
  takeLatest(LabLocationTypes.CREATE_REQUEST, create),
  takeLatest(LabLocationTypes.UPDATE_REQUEST, update),
  takeLatest(LabLocationTypes.DELETE_REQUEST, remove),
]
Example #15
Source File: index.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
// Saga watchers
function* watchOpenToaster() {
  yield takeLatest(getType(openToasterCreator), openToasterSaga);
}
Example #16
Source File: index.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
// Saga watchers
function* watchCreateSlice() {
  yield takeLatest(
    getType(createSliceCreator.request),
    withLoader(createSliceSaga, LoadingKeysEnum.CREATE_SLICE)
  );
}
Example #17
Source File: index.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
// Saga watchers
function* watchCheckSetup() {
  yield takeLatest(
    getType(checkSimulatorSetupCreator.request),
    withLoader(checkSetupSaga, LoadingKeysEnum.CHECK_SIMULATOR)
  );
  yield takeLatest(getType(openSetupDrawerCreator), trackOpenSetupDrawerSaga);
}
Example #18
Source File: sagas.ts    From generator-earth with MIT License 5 votes vote down vote up
export default function* asyncSagas() {
    yield all([
        yield takeLatest(LIST__SUBMIT_FORM_ASYNC, submitFormAsync),
    ])
}
Example #19
Source File: sagas.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
// Saga watchers
function* watchSaveCustomType() {
  yield takeLatest(
    getType(saveCustomTypeCreator.request),
    withLoader(saveCustomTypeSaga, LoadingKeysEnum.SAVE_CUSTOM_TYPE)
  );
}
Example #20
Source File: index.ts    From slice-machine with Apache License 2.0 5 votes vote down vote up
// Saga watchers
function* watchCreateCustomType() {
  yield takeLatest(
    getType(createCustomTypeCreator.request),
    withLoader(createCustomTypeSaga, LoadingKeysEnum.CREATE_CUSTOM_TYPE)
  );
}
Example #21
Source File: user-saga.ts    From Riakuto-StartingReact-ja3.1 with Apache License 2.0 5 votes vote down vote up
export function* watchGetMembers() {
  yield takeLatest(getMembersStarted, runGetMembers);
}
Example #22
Source File: Products.saga.ts    From react-native-woocommerce with MIT License 5 votes vote down vote up
export function* watchRefetchProducts() {
  // @ts-ignore
  yield takeLatest(constant.REFETCH_PRODUCTS, refetchProducts);
}
Example #23
Source File: Products.saga.ts    From react-native-woocommerce with MIT License 5 votes vote down vote up
export function* watchProductsEndReached() {
  // @ts-ignore
  yield takeLatest(constant.PRODUCTS_END_REACHED, getProducts);
}
Example #24
Source File: Products.saga.ts    From react-native-woocommerce with MIT License 5 votes vote down vote up
export function* watchProductsQuery() {
  // @ts-ignore
  yield takeLatest(constant.PRODUCTS_QUERY, initialGetProducts);
}
Example #25
Source File: Checkout.saga.ts    From react-native-woocommerce with MIT License 5 votes vote down vote up
export function* watchCheckoutCommand() {
  // @ts-ignore
  yield takeLatest(constant.CHECKOUT_COMMAND, sendOrder);
}
Example #26
Source File: sagas.ts    From firebase-tools-ui with Apache License 2.0 5 votes vote down vote up
export function* authSaga() {
  yield takeLatest(getType(updateAuthConfig), initAuth);
}
Example #27
Source File: sagas.ts    From generator-earth with MIT License 5 votes vote down vote up
export default function* asyncSagas() {
    yield all([
        yield takeLatest(LIST__SUBMIT_FORM_ASYNC, submitFormAsync),
    ])
}