How to use the redux-saga/effects.take 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 microsoft / BotFramework-WebChat / packages / core / src / sagas / connectSaga.js View on Github external
try {
      const endDirectLine = yield runAsyncEffectUntilDisconnect(
        {
          type: CONNECT,
          meta,
          payload: { directLine }
        },
        () => call(connectSaga, directLine)
      );

      try {
        for (;;) {
          // We are waiting for connection status change or disconnect action.
          const { updateConnectionStatusAction: { payload: { connectionStatus } = {} } = {} } = yield race({
            _: take(DISCONNECT),
            updateConnectionStatusAction: take(UPDATE_CONNECTION_STATUS)
          });

          // If it is not disconnect action, connectionStatus will not be undefined.
          if (connectionStatus === CONNECTING) {
            // If DirectLineJS changed connectionStatus to CONNECTING, we will treat it as reconnect status.
            yield runAsyncEffectUntilDisconnect(
              {
                type: RECONNECT,
                meta,
                payload: { directLine }
              },
              () => call(reconnectSaga)
            );
          } else if (connectionStatus !== ONLINE) {
            if (typeof connectionStatus !== 'undefined') {
              // We need to kill the connection because DirectLineJS want to close it.
github Altinn / altinn-studio / src / Altinn.Apps / AppFrontend / react / altinn-app-frontend / src / features / form / data / update / updateFormDataSagas.ts View on Github external
export function* watchUpdateFormDataSaga(): SagaIterator {
  const requestChan = yield actionChannel(FormDataActionTypes.UPDATE_FORM_DATA);
  while (true) {
    const value = yield take(requestChan);
    yield call(updateFormDataSaga, value);
  }
}
github LeadcoinNetwork / Web-App-Project / frontend / src / sagas / myLeads.js View on Github external
)

    let res = yield api.leads.getMyLeads({
      page,
      limit,
      sortBy,
      category,
    })

    if (res.error) {
      yield put(actions.leads.fetchError("MY_LEADS"))
    } else {
      yield put(actions.leads.fetchSuccess("MY_LEADS", res))
    }

    yield take([
      types.MY_LEADS_FETCH_LEADS,
      types.CHECKOUT_BUY_SUCCESS,
      types.MY_LEADS_MOVE_TO_SELL_SUCCESS,
      types.LOGIN_FINISH,
      types.LOGGED_OUT,
    ])
  }
}
github pekkis / hardcore-react-training / client / src / sagas / person.js View on Github external
export function* loggedInActions() {
  do {
    yield take(LOGIN_SUCCESS);

    const task = yield fork(function*() {
      yield all([
        takeEvery(FIRE_PERSON, function*(action) {
          yield call(firePerson, action.payload);
        }),
        takeEvery(HIRE_PERSON, function*(action) {
          yield call(hirePerson, action.payload);
        })
      ]);
    });

    yield take(LOGOUT);
    task.cancel();
  } while (true);
}
github golemfactory / golem-electron / src / sagas / index.js View on Github external
export function* flow() {
    while (true) {
        yield take(LOGIN)

        yield put({
            type: SET_GOLEM_STATUS,
            payload: {
                message: 'Starting Golem'
            }
        })

        const {connection} = yield call(connect)
        const task = yield fork(handleIO, connection)
        let action = yield take(LOGOUT)
        yield cancel(task)
    }
}
github RocketChat / Rocket.Chat.ReactNative / app / sagas / rooms.js View on Github external
const root = function* root() {
	while (true) {
		const params = yield take(types.ROOMS.REQUEST);
		const isAuthenticated = yield select(state => state.login.isAuthenticated);
		if (isAuthenticated) {
			const roomsRequestTask = yield fork(handleRoomsRequest, params);
			yield race({
				roomsSuccess: take(types.ROOMS.SUCCESS),
				roomsFailure: take(types.ROOMS.FAILURE),
				serverReq: take(types.SERVER.SELECT_REQUEST),
				background: take(BACKGROUND),
				inactive: take(INACTIVE),
				logout: take(types.LOGOUT),
				timeout: delay(30000)
			});
			yield cancel(roomsRequestTask);
		}
	}
};
export default root;
github reportportal / service-ui / app / src / controllers / log / attachments / sagas.js View on Github external
function* fetchAttachmentsConcat({ payload: { params, concat } }) {
  const url = yield call(getAttachmentURL);
  yield put(concatFetchDataAction(ATTACHMENTS_NAMESPACE, concat)(url, { params }));
  yield take(createFetchPredicate(ATTACHMENTS_NAMESPACE));
}
github yjf27281181 / react-readme / src / sagas / frontSaga.js View on Github external
export function* getCommentsFlow() {
  while (true) {
    let request = yield take(frontActionTypes.GET_COMMENTS);
    var { question_id } = request;
    let response = yield call(getComments, question_id);
    if (response && response.code === 0) {
      yield put({
        type: IndexActionTypes.SET_MESSAGE,
        msgContent: "post comment success",
        msgType: 1
      });
      yield put({
        type: frontActionTypes.RESPONSE_COMMENTS,
        comments: response.comments
      });
    }
  }
}