How to use the @redux-saga/core/effects.put 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 ETCDEVTeam / emerald-wallet / packages / store / src / accounts / sagas.ts View on Github external
function* fetchErc20Balances (api: IApi, action: IFetchErc20BalancesAction): SagaIterator {
  const accounts: AddressMap[] = yield select(allAsArray);
  for (const acc of accounts) {
    const address = acc.get('id');
    const chain = acc.get('blockchain').toLowerCase();

    // Look up all known tokens for current blockchain
    const _tokens = registry.all()[chain as BlockchainCode];

    // Request balance for each token for current address
    for (const t of _tokens) {
      yield put(requestTokenBalance(chain, t, address));
    }
  }
}
github ant-design / ant-design-landing / site / shared / redux / saga.js View on Github external
function* handleCreateNewTemplate(action) {
  const { data } = action;
  try {
    const template = yield newTemplate(DEFAULT_USER_NAME, data);

    yield put({
      type: POST_TYPE.POST_SUCCESS,
      templateData: template,
    });
  } catch (error) {
    console.error(error);
  }
}
github uprtcl / js-uprtcl / modules / evees / src / state / evees.sagas.ts View on Github external
function* filterPerspectiveEntity(action: LoadEntitySuccess) {
  const perspectivePattern: PerspectiveEntity = (yield getContext(ReduxTypes.Context)).get(
    EveesTypes.PerspectivePattern
  );

  if (perspectivePattern.recognize(action.payload.entity)) {
    const loadPerspectiveDetailsAction: LoadPerspectiveDetails = {
      type: LOAD_PERSPECTIVE_DETAILS,
      payload: { perspectiveId: action.payload.hash }
    };
    yield put(loadPerspectiveDetailsAction);
  }
}
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
            ));
            break;
        }
github Jameskmonger / creature-chess / src / shared / board / sagas / evolution.ts View on Github external
if (totalInstances < PIECES_TO_EVOLVE) {
                        return;
                    }

                    const newBoard = board.filter(p => p.id !== piece.id && pieceIsMatching(p) === false);
                    const newBench = bench.filter(p => p.id !== piece.id && pieceIsMatching(p) === false);

                    const slot = getFirstEmptyBenchSlot(newBench);

                    const newPiece = {
                        ...piece,
                        stage: nextStageIndex,
                        position: createTileCoordinates(slot, null)
                    };

                    yield put(BoardActions.piecesUpdated(newBoard));
                    yield put(BenchActions.benchPiecesUpdated(newBench));
                    yield put(BenchActions.benchPieceAdded(newPiece));
                }
            )
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
            ));
            break;
        }

        yield put(joinGameError(error));
        action = yield take([FIND_GAME, JOIN_GAME, CREATE_GAME]);
    }

    yield fork(writeActionsToPackets);
    yield fork(writePacketsToSocket, socket);
};
github Jameskmonger / creature-chess / src / shared / board / sagas / evolution.ts View on Github external
}

                    const newBoard = board.filter(p => p.id !== piece.id && pieceIsMatching(p) === false);
                    const newBench = bench.filter(p => p.id !== piece.id && pieceIsMatching(p) === false);

                    const slot = getFirstEmptyBenchSlot(newBench);

                    const newPiece = {
                        ...piece,
                        stage: nextStageIndex,
                        position: createTileCoordinates(slot, null)
                    };

                    yield put(BoardActions.piecesUpdated(newBoard));
                    yield put(BenchActions.benchPiecesUpdated(newBench));
                    yield put(BenchActions.benchPieceAdded(newPiece));
                }
            )
github Jameskmonger / creature-chess / src / app / store / sagas / actions / phaseTimer.ts View on Github external
yield takeLatest(GAME_PHASE_UPDATE, function*(action) {
        const phaseLength = Constants.PHASE_LENGTHS[action.payload.phase];

        if (phaseLength) {
            yield put(phaseTimerUpdated(phaseLength));

            const channel = yield call(countdown, phaseLength);

            yield takeEvery(channel, function*(secs: number) {
                yield put(phaseTimerUpdated(secs));
            });
        }
    });
};
github Jameskmonger / creature-chess / src / app / store / sagas / actions / gamePhase.ts View on Github external
function*(action) {
                const pieces = (action.payload as any).payload.pieces;

                yield put(BoardActions.piecesUpdated(pieces));
                yield put(LockEvolutionActions.lockEvolutionAction());
            }
        ),
github uprtcl / js-uprtcl / packages / common / src / access-control / state / access-control.sagas.ts View on Github external
function* filterUpdatableEntity(action: LoadEntitySuccess) {
  const recognizer: PatternRecognizer = (yield getContext(ReduxTypes.Context)).get(
    PatternTypes.Recognizer
  );

  const updatable: Updatable | undefined = recognizer.recognizeUniqueProperty(
    action.payload.entity,
    prop => !!(prop as Updatable).update
  );

  if (updatable) {
    const accessControlAction: LoadAccessControl = {
      type: LOAD_ACCESS_CONTROL,
      payload: action.payload
    };
    yield put(accessControlAction);
  }
}