Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function*() {
const sagaState = {
evolutionLocked: false
};
yield all([
yield takeLatest(
[ LOCK_EVOLUTIONS, UNLOCK_EVOLUTIONS ],
function*(action) {
sagaState.evolutionLocked = (action.type === LOCK_EVOLUTIONS);
}
),
yield takeLatest(
BenchActionTypes.BENCH_PIECE_ADDED,
function*(action) {
const piece = action.payload.piece;
// if evolution is locked, wait for it to be unlocked
if (sagaState.evolutionLocked) {
yield take(UNLOCK_EVOLUTIONS);
yield delay(500);
}
const { bench, board }: TState = yield select(s => ({ bench: s.bench, board: s.board }));
const { stages } = definitionProvider.get(piece.definitionId);
const nextStageIndex = piece.stage + 1;
const nextStage = stages[nextStageIndex];
return function*() {
const sagaState = {
evolutionLocked: false
};
yield all([
yield takeLatest(
[ LOCK_EVOLUTIONS, UNLOCK_EVOLUTIONS ],
function*(action) {
sagaState.evolutionLocked = (action.type === LOCK_EVOLUTIONS);
}
),
yield takeLatest(
BenchActionTypes.BENCH_PIECE_ADDED,
function*(action) {
const piece = action.payload.piece;
// if evolution is locked, wait for it to be unlocked
if (sagaState.evolutionLocked) {
yield take(UNLOCK_EVOLUTIONS);
yield delay(500);
}
export function* root (api: IApi) {
yield takeLatest(ActionTypes.FETCH_HD_PATHS, fetchHdPaths, api);
yield takeLatest(ActionTypes.FETCH_ERC20_BALANCES, fetchErc20Balances, api);
}
export function* root (api: IApi) {
yield takeLatest(ActionTypes.FETCH_HD_PATHS, fetchHdPaths, api);
yield takeLatest(ActionTypes.FETCH_ERC20_BALANCES, fetchErc20Balances, api);
}
const clearNotifications = function*() {
yield takeLatest(BANNER_UPDATED, function*() {
yield delay(1000);
yield put(bannerUpdatedAction(null));
});
};
const sendNotifications = function*() {
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`));
});
});
};
export const phaseTimer = function*() {
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));
});
}
});
};