summaryrefslogtreecommitdiff
path: root/frontend/src/sagas.js
blob: 4a93ffb4a43a73a004884887b8288697ffd2be54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// @flow
import type { History } from 'react-router';
import { call, fork } from 'redux-saga/effects';
import { connectToGame, SevenWondersSession } from './api/sevenWondersApi';
import errorHandlingSaga from './sagas/errors';
import homeSaga from './sagas/home';
import gameBrowserSaga from './sagas/gameBrowser';
import lobbySaga from './sagas/lobby';

export default function* rootSaga(history: History): * {
  let sevenWondersSession: SevenWondersSession | void;
  try {
    sevenWondersSession = yield call(connectToGame);
  } catch (error) {
    console.error('Could not connect to socket', error);
    return;
  }
  yield fork(errorHandlingSaga, sevenWondersSession);
  yield fork(homeSaga, sevenWondersSession);
  yield fork(gameBrowserSaga, sevenWondersSession);
  yield fork(lobbySaga, sevenWondersSession);
}
bgstack15