summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorVictor Chabbert <chabbertvi@eisti.eu>2017-01-20 18:32:14 +0100
committerVictor Chabbert <chabbertvi@eisti.eu>2017-01-20 23:25:26 +0100
commitcf91a05903b11ce7c41efc27a89179ffd855ec1c (patch)
treeae3c4a9aaa66375570483f29f38907f50ce13730 /frontend/src
parentRemove build matrix as we don't need a macOS build (diff)
downloadseven-wonders-cf91a05903b11ce7c41efc27a89179ffd855ec1c.tar.gz
seven-wonders-cf91a05903b11ce7c41efc27a89179ffd855ec1c.tar.bz2
seven-wonders-cf91a05903b11ce7c41efc27a89179ffd855ec1c.zip
Update deps, Add redux-saga-router
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/containers/HomePage/index.js3
-rw-r--r--frontend/src/containers/HomePage/saga.js2
-rw-r--r--frontend/src/sagas.js24
-rw-r--r--frontend/src/store.js6
4 files changed, 23 insertions, 12 deletions
diff --git a/frontend/src/containers/HomePage/index.js b/frontend/src/containers/HomePage/index.js
index c8e33239..a00f46ae 100644
--- a/frontend/src/containers/HomePage/index.js
+++ b/frontend/src/containers/HomePage/index.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { Heading, InlineForm } from 'rebass'
-
+import { Link } from 'react-router'
class HomePage extends Component {
play = (e) => {
@@ -22,6 +22,7 @@ class HomePage extends Component {
onChange={(e) => this._username = e.target.value}
onClick={this.play}
/>
+ <Link to="/somewhere">Take me somewhere</Link>
</div>
)
}
diff --git a/frontend/src/containers/HomePage/saga.js b/frontend/src/containers/HomePage/saga.js
index 0fbe8a45..349a1d15 100644
--- a/frontend/src/containers/HomePage/saga.js
+++ b/frontend/src/containers/HomePage/saga.js
@@ -39,11 +39,11 @@ function* validateUsername(socketConnection) {
}
yield put(setUsername(response.userName, response.displayName, response.index))
- yield call(gameBrowserSaga, socketConnection)
return true
}
function* homeSaga(socketConnection) {
+ console.log('here')
let validated = false
do {
const [, usernameValid] = yield [
diff --git a/frontend/src/sagas.js b/frontend/src/sagas.js
index 58ef73ee..2e34a0b7 100644
--- a/frontend/src/sagas.js
+++ b/frontend/src/sagas.js
@@ -1,12 +1,21 @@
-import { fork, call } from 'redux-saga/effects'
+import { router } from 'redux-saga-router'
+import { call } from 'redux-saga/effects'
import createWsConnection from './utils/createWebSocketConnection'
-import errorSaga from './containers/App/saga'
+
+// import errorSaga from './containers/App/saga'
import homeSaga from './containers/HomePage/saga'
-function* wsAwareSagas() {
- let wsConnection
+let wsConnection
+const routes = {
+ *'/'() {
+ yield console.info('home saga running')
+ yield homeSaga(wsConnection)
+ }
+}
+
+function* wsAwareSagas(history) {
try {
wsConnection = yield call(createWsConnection)
} catch (error) {
@@ -14,12 +23,11 @@ function* wsAwareSagas() {
return
}
- yield fork(errorSaga, wsConnection)
- yield fork(homeSaga, wsConnection)
+ yield* router(history, routes)
}
-export default function* rootSaga() {
+export default function* rootSaga(history) {
yield [
- call(wsAwareSagas)
+ call(wsAwareSagas, history)
]
}
diff --git a/frontend/src/store.js b/frontend/src/store.js
index e9ac401e..750c9c72 100644
--- a/frontend/src/store.js
+++ b/frontend/src/store.js
@@ -31,10 +31,12 @@ export default function configureStore(initialState = {}) {
composeEnhancers(...enhancers)
)
- sagaMiddleware.run(rootSaga)
+ const syncedHistory = syncHistoryWithStore(history, store)
+
+ sagaMiddleware.run(rootSaga, syncedHistory)
return {
store,
- history: syncHistoryWithStore(history, store)
+ history: syncedHistory
}
}
bgstack15