From ca90094c8fb30ffd29f6d53f2d2ac71f55a45e94 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Mon, 30 Apr 2018 00:22:26 +0200 Subject: Fix sagas types --- frontend/src/sagas/errors.js | 4 ++-- frontend/src/sagas/gameBrowser.js | 11 ++++++----- frontend/src/sagas/home.js | 8 ++++---- frontend/src/sagas/lobby.js | 10 +++++----- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/sagas/errors.js b/frontend/src/sagas/errors.js index 6598da6c..84bd044b 100644 --- a/frontend/src/sagas/errors.js +++ b/frontend/src/sagas/errors.js @@ -1,12 +1,12 @@ // @flow import { toastr } from 'react-redux-toastr'; -import type { Channel } from 'redux-saga'; +import type { Channel, SagaIterator } from 'redux-saga'; import { eventChannel } from 'redux-saga'; import { apply, cancelled, take } from 'redux-saga/effects'; import type { ApiError } from '../api/model'; import type { SevenWondersSession } from '../api/sevenWondersApi'; -export function* errorHandlingSaga(session: SevenWondersSession): * { +export function* errorHandlingSaga(session: SevenWondersSession): SagaIterator { const errorChannel: Channel = yield eventChannel(session.watchErrors()); try { while (true) { diff --git a/frontend/src/sagas/gameBrowser.js b/frontend/src/sagas/gameBrowser.js index 95326a2b..7cd45667 100644 --- a/frontend/src/sagas/gameBrowser.js +++ b/frontend/src/sagas/gameBrowser.js @@ -1,6 +1,7 @@ // @flow import { normalize } from 'normalizr'; import { push } from 'react-router-redux'; +import type { SagaIterator } from 'redux-saga'; import { eventChannel } from 'redux-saga'; import { all, apply, call, put, take } from 'redux-saga/effects'; import type { SevenWondersSession } from '../api/sevenWondersApi'; @@ -8,7 +9,7 @@ import { actions as gameActions, types } from '../redux/games'; import { actions as playerActions } from '../redux/players'; import { game as gameSchema, gameList as gameListSchema } from '../schemas/games'; -function* watchGames(session: SevenWondersSession): * { +function* watchGames(session: SevenWondersSession): SagaIterator { const gamesChannel = yield eventChannel(session.watchGames()); try { while (true) { @@ -23,7 +24,7 @@ function* watchGames(session: SevenWondersSession): * { } } -function* watchLobbyJoined(session: SevenWondersSession): * { +function* watchLobbyJoined(session: SevenWondersSession): SagaIterator { const joinedLobbyChannel = yield eventChannel(session.watchLobbyJoined()); try { const joinedLobby = yield take(joinedLobbyChannel); @@ -38,7 +39,7 @@ function* watchLobbyJoined(session: SevenWondersSession): * { } } -function* createGame(session: SevenWondersSession): * { +function* createGame(session: SevenWondersSession): SagaIterator { while (true) { const { gameName } = yield take(types.REQUEST_CREATE_GAME); // $FlowFixMe @@ -46,7 +47,7 @@ function* createGame(session: SevenWondersSession): * { } } -function* joinGame(session: SevenWondersSession): * { +function* joinGame(session: SevenWondersSession): SagaIterator { while (true) { const { gameId } = yield take(types.REQUEST_JOIN_GAME); // $FlowFixMe @@ -54,7 +55,7 @@ function* joinGame(session: SevenWondersSession): * { } } -export function* gameBrowserSaga(session: SevenWondersSession): * { +export function* gameBrowserSaga(session: SevenWondersSession): SagaIterator { yield all([ call(watchGames, session), call(watchLobbyJoined, session), diff --git a/frontend/src/sagas/home.js b/frontend/src/sagas/home.js index c55986c3..328102fb 100644 --- a/frontend/src/sagas/home.js +++ b/frontend/src/sagas/home.js @@ -1,13 +1,13 @@ // @flow import { push } from 'react-router-redux'; +import type { SagaIterator } from 'redux-saga'; import { eventChannel } from 'redux-saga'; import { all, apply, call, put, take } from 'redux-saga/effects'; import type { ApiPlayer } from '../api/model'; import type { SevenWondersSession } from '../api/sevenWondersApi'; - import { actions, types } from '../redux/players'; -function* sendUsername(session: SevenWondersSession): * { +function* sendUsername(session: SevenWondersSession): SagaIterator { while (true) { const { username } = yield take(types.REQUEST_CHOOSE_USERNAME); // $FlowFixMe @@ -15,7 +15,7 @@ function* sendUsername(session: SevenWondersSession): * { } } -function* validateUsername(session: SevenWondersSession): * { +function* validateUsername(session: SevenWondersSession): SagaIterator { const usernameChannel = yield eventChannel(session.watchNameChoice()); while (true) { const user: ApiPlayer = yield take(usernameChannel); @@ -25,6 +25,6 @@ function* validateUsername(session: SevenWondersSession): * { } } -export function* homeSaga(session: SevenWondersSession): * { +export function* homeSaga(session: SevenWondersSession): SagaIterator { yield all([call(sendUsername, session), call(validateUsername, session)]); } diff --git a/frontend/src/sagas/lobby.js b/frontend/src/sagas/lobby.js index f884910d..c87f6ad5 100644 --- a/frontend/src/sagas/lobby.js +++ b/frontend/src/sagas/lobby.js @@ -1,7 +1,7 @@ // @flow import { normalize } from 'normalizr'; import { push } from 'react-router-redux'; -import type { Channel } from 'redux-saga'; +import type { Channel, SagaIterator } from 'redux-saga'; import { eventChannel } from 'redux-saga'; import { all, apply, call, put, take } from 'redux-saga/effects'; import { SevenWondersSession } from '../api/sevenWondersApi'; @@ -14,7 +14,7 @@ function getCurrentGameId(): number { return path.split('lobby/')[1]; } -function* watchLobbyUpdates(session: SevenWondersSession): * { +function* watchLobbyUpdates(session: SevenWondersSession): SagaIterator { const currentGameId: number = getCurrentGameId(); const lobbyUpdatesChannel: Channel = yield eventChannel(session.watchLobbyUpdated(currentGameId)); try { @@ -29,7 +29,7 @@ function* watchLobbyUpdates(session: SevenWondersSession): * { } } -function* watchGameStart(session: SevenWondersSession): * { +function* watchGameStart(session: SevenWondersSession): SagaIterator { const currentGameId = getCurrentGameId(); const gameStartedChannel = yield eventChannel(session.watchGameStarted(currentGameId)); try { @@ -41,13 +41,13 @@ function* watchGameStart(session: SevenWondersSession): * { } } -function* startGame(session: SevenWondersSession): * { +function* startGame(session: SevenWondersSession): SagaIterator { while (true) { yield take(types.REQUEST_START_GAME); yield apply(session, session.startGame, []); } } -export function* lobbySaga(session: SevenWondersSession): * { +export function* lobbySaga(session: SevenWondersSession): SagaIterator { yield all([call(watchLobbyUpdates, session), call(watchGameStart, session), call(startGame, session)]); } -- cgit