summaryrefslogtreecommitdiff
path: root/sw-ui/src/sagas.ts
blob: 03c71b630c1c3954ac7cd9145fac42e1ad687d84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { SagaIterator } from 'redux-saga';
import { call, fork } from 'redux-saga/effects';
import { connectToGame, SevenWondersSession } from './api/sevenWondersApi';
import { errorHandlingSaga } from './sagas/errors';
import { gameSaga } from './sagas/game';
import { gameBrowserSaga } from './sagas/gameBrowser';
import { homeSaga } from './sagas/home';
import { lobbySaga } from './sagas/lobby';

export function* rootSaga(): SagaIterator {
  let sevenWondersSession: SevenWondersSession;
  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);
  yield fork(gameSaga, sevenWondersSession);
}
bgstack15