How to use the @redux-saga/core/effects.call function in @redux-saga/core

To help you get started, we’ve selected a few @redux-saga/core 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 Jameskmonger / creature-chess / src / app / sagas / actions / processBattle.ts View on Github external
function*(action) {
            if (isGamePhaseUpdate(GamePhase.PREPARING, action) || isGamePhaseUpdate(GamePhase.READY, action)) {
                // don't do anything, just cancel the old one
                const pieces = (action.payload as any).payload.pieces;

                yield put(BoardActions.piecesUpdated(pieces));
                return;
            }

            const state: AppState = yield select();

            const battleChannel = yield call(startBattle, turnSimulator, state.board, Constants.TURNS_IN_BATTLE);

            yield takeEvery(battleChannel, function*(battleAction: BattleAction) {
                switch (battleAction.type) {
                    case BATTLE_TURN:
                        yield put(BoardActions.piecesUpdated(battleAction.payload.pieces));
                    case BATTLE_FINISHED:
                        yield put(battleAction);
                    default:
                        return;
                }
            });
        }
    );
github Jameskmonger / creature-chess / src / shared / match / combat / battleSaga.ts View on Github external
function*() {
            const { board }: TState = yield select();

            const battleChannel = yield call(battleEventChannel, turnSimulator, turnDuration, board, turnCount);

            yield takeEvery(battleChannel, function*(battleAction: BattleAction) {
                yield put(battleAction);
            });
        }
    );
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
const getResponseForAction = (socket: Socket, action: FindGameAction | JoinGameAction | CreateGameAction) => {
    if (action.type === JOIN_GAME) {
        return call(joinGame, socket, action.payload.name, action.payload.gameId);
    }

    if (action.type === FIND_GAME) {
        return call(findGame, socket, action.payload.name);
    }

    if (action.type === CREATE_GAME) {
        return call(createGame, socket, action.payload.name);
    }
};
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
const getResponseForAction = (socket: Socket, action: FindGameAction | JoinGameAction | CreateGameAction) => {
    if (action.type === JOIN_GAME) {
        return call(joinGame, socket, action.payload.name, action.payload.gameId);
    }

    if (action.type === FIND_GAME) {
        return call(findGame, socket, action.payload.name);
    }

    if (action.type === CREATE_GAME) {
        return call(createGame, socket, action.payload.name);
    }
};
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
export const networking = function*() {
    let action: (FindGameAction | JoinGameAction | CreateGameAction)
        = yield take([FIND_GAME, JOIN_GAME, CREATE_GAME]);
    const socket: Socket = yield call(getSocket, action.payload.serverIP);

    yield put(updateConnectionStatus(ConnectionStatus.CONNECTED));

    yield fork(readPacketsToActions, socket);

    while (true) {
        const { error, response }: JoinLobbyResponse = yield getResponseForAction(socket, action);

        if (!error) {
            yield put(joinLobbyAction(
                response.playerId,
                response.lobbyId,
                response.players,
                response.startTimestamp,
                response.isHost
            ));
github ETCDEVTeam / emerald-wallet / packages / store / src / accounts / sagas.ts View on Github external
function* fetchHdPaths (api: IApi, action: IFetchHdPathsAction) {
  const accounts: AddressList = yield select(all);
  const hwAccounts: AddressMap[] = accounts.filter((a: any) => a.get('hardware', true)).toArray();
  for (const item of hwAccounts) {
    const address = item.get('id');
    const chain = item.get('blockchain').toLowerCase();
    const result = yield call(api.emerald.exportAccount, address, chain);

    yield put({
      type: ActionTypes.SET_HD_PATH,
      accountId: address,
      hdpath: result.crypto.hd_path,
      blockchain: chain
    });
  }
}
github uprtcl / js-uprtcl / modules / evees / src / state / evees.sagas.ts View on Github external
function* loadPerspectiveDetails(action: LoadPerspectiveDetails) {
  const evees: Evees = (yield getContext(ReduxTypes.Context)).get(EveesTypes.Evees);
  const details = yield call(() => evees.getPerspectiveDetails(action.payload.perspectiveId));

  const successAction: LoadPerspectiveDetailsSuccess = {
    type: LOAD_PERSPECTIVE_DETAILS_SUCCESS,
    payload: {
      perspectiveId: action.payload.perspectiveId,
      details
    }
  };
  yield put(successAction);
}
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
const getResponseForAction = (socket: Socket, action: FindGameAction | JoinGameAction | CreateGameAction) => {
    if (action.type === JOIN_GAME) {
        return call(joinGame, socket, action.payload.name, action.payload.gameId);
    }

    if (action.type === FIND_GAME) {
        return call(findGame, socket, action.payload.name);
    }

    if (action.type === CREATE_GAME) {
        return call(createGame, socket, action.payload.name);
    }
};