How to use the @redux-saga/core/effects.takeEvery 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 / store / sagas / actions / networking.ts View on Github external
yield put(sendPacket(ClientToServerPacketOpcodes.BUY_REROLL));
            }
        ),
        takeEvery(
            BUY_XP,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_XP));
            }
        ),
        takeEvery(
            READY_UP,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.READY_UP));
            }
        ),
        takeEvery>(
            BUY_CARD,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_CARD, payload.index));
            }
        ),
        takeEvery>(
            BoardActionTypes.SELL_PIECE,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.SELL_PIECE, payload.pieceId));
            }
        ),
        takeEvery>(
            BoardActionTypes.PIECE_MOVED_TO_BOARD,
            function*({ payload }) {
                const packet: MovePiecePacket = {
                    id: payload.piece.id,
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
const writeActionsToPackets = function*() {
    yield all([
        takeEvery(
            BATTLE_FINISHED,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.FINISH_MATCH));
            }
        ),
        takeEvery(
            REROLL_CARDS,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_REROLL));
            }
        ),
        takeEvery(
            BUY_XP,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_XP));
            }
        ),
        takeEvery(
            READY_UP,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.READY_UP));
            }
        ),
        takeEvery>(
            BUY_CARD,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_CARD, payload.index));
            }
github Jameskmonger / creature-chess / src / app / sagas / actions / notifications.ts View on Github external
yield takeLatest(GAME_STATE_UPDATE, function*(action) {
        const stateLength = Constants.STATE_LENGTHS[action.payload.phase];

        if (stateLength) {
            yield put(bannerUpdatedAction(`${GameState[action.payload.phase]}, ${stateLength} seconds`));
        }

        const channel = yield call(countdown, stateLength);
        yield takeEvery(channel, function*(secs) {
            yield put(bannerUpdatedAction(`${GameState[action.payload.phase]}, ${secs} seconds`));
        });
    });
};
github Jameskmonger / creature-chess / src / shared / match / combat / battleSaga.ts View on Github external
export const battle = function*(turnSimulator: TurnSimulator, turnCount: number, turnDuration: number) {
    yield takeEvery(
        START_BATTLE,
        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 ant-design / ant-design-landing / site / shared / redux / saga.js View on Github external
export default function* () {
  yield takeEvery(GET_USER_DATA, handleGetUserData);
  yield takeEvery(CREATE_NEW_TEMPLATE, handleCreateNewTemplate);
  yield takeEvery(SET_TEMPLATE_DATA, handleSetTemplateData);
  yield takeEvery(CHANGE_CHILD, handleChangeChild);
  yield takeEvery(SET_USER_AND_TEMPLATE_DATA, handleSetUserAndTemplateData);
}
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
yield put(sendPacket(ClientToServerPacketOpcodes.MOVE_PIECE_TO_BOARD, packet));
            }
        ),
        takeEvery>(
            BoardActionTypes.PIECE_MOVED_TO_BENCH,
            function*({ payload }) {
                const packet: MovePiecePacket = {
                    id: payload.piece.id,
                    from: payload.piece.position,
                    to: createTileCoordinates(payload.slot, null)
                };

                yield put(sendPacket(ClientToServerPacketOpcodes.MOVE_PIECE_TO_BENCH, packet));
            }
        ),
        takeEvery>(
            SEND_CHAT_MESSAGE,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.SEND_CHAT_MESSAGE, payload.message));
            }
        ),
        takeEvery(
            START_LOBBY_GAME,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.START_LOBBY_GAME));
            }
        ),
        takeEvery(
            TOGGLE_SHOP_LOCK,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.TOGGLE_SHOP_LOCK));
            }
github uprtcl / js-uprtcl / modules / evees / src / state / evees.sagas.ts View on Github external
export const loadPerspectiveDetailsSaga: Saga = function*() {
  yield takeEvery(LOAD_PERSPECTIVE_DETAILS, loadPerspectiveDetails);
};
github ant-design / ant-design-landing / site / shared / redux / saga.js View on Github external
export default function* () {
  yield takeEvery(GET_USER_DATA, handleGetUserData);
  yield takeEvery(CREATE_NEW_TEMPLATE, handleCreateNewTemplate);
  yield takeEvery(SET_TEMPLATE_DATA, handleSetTemplateData);
  yield takeEvery(CHANGE_CHILD, handleChangeChild);
  yield takeEvery(SET_USER_AND_TEMPLATE_DATA, handleSetUserAndTemplateData);
}
github Jameskmonger / creature-chess / src / app / store / sagas / actions / networking.ts View on Github external
yield put(sendPacket(ClientToServerPacketOpcodes.BUY_XP));
            }
        ),
        takeEvery(
            READY_UP,
            function*() {
                yield put(sendPacket(ClientToServerPacketOpcodes.READY_UP));
            }
        ),
        takeEvery>(
            BUY_CARD,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.BUY_CARD, payload.index));
            }
        ),
        takeEvery>(
            BoardActionTypes.SELL_PIECE,
            function*({ payload }) {
                yield put(sendPacket(ClientToServerPacketOpcodes.SELL_PIECE, payload.pieceId));
            }
        ),
        takeEvery>(
            BoardActionTypes.PIECE_MOVED_TO_BOARD,
            function*({ payload }) {
                const packet: MovePiecePacket = {
                    id: payload.piece.id,
                    from: payload.piece.position,
                    to: payload.position
                };

                yield put(sendPacket(ClientToServerPacketOpcodes.MOVE_PIECE_TO_BOARD, packet));
            }