summaryrefslogtreecommitdiff
path: root/frontend/src/sagas.js
blob: e43e91c27c01a01f9d0532e37bf5ed88e47c4664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { router } from 'redux-saga-router'
import { call } from 'redux-saga/effects'

import createWsConnection from './utils/createWebSocketConnection'

import usernameChoiceSaga from './sagas/usernameChoice'

let wsConnection
const routes = {
  *'/'() {
    yield usernameChoiceSaga(wsConnection)
  }
}

export default function *rootSaga(history) {
  try {
    wsConnection = yield call(createWsConnection)
  } catch (error) {
    console.error('Could not connect to socket')
    return
  }

  yield* router(history, routes)
}
bgstack15