From cf91a05903b11ce7c41efc27a89179ffd855ec1c Mon Sep 17 00:00:00 2001 From: Victor Chabbert Date: Fri, 20 Jan 2017 18:32:14 +0100 Subject: Update deps, Add redux-saga-router --- frontend/package.json | 13 ++--- frontend/src/containers/HomePage/index.js | 3 +- frontend/src/containers/HomePage/saga.js | 2 +- frontend/src/sagas.js | 24 ++++++--- frontend/src/store.js | 6 ++- frontend/yarn.lock | 88 ++++++++++++++++++++----------- 6 files changed, 88 insertions(+), 48 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 34632161..ef688fde 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,19 +3,20 @@ "version": "0.1.0", "private": true, "devDependencies": { - "react-scripts": "0.8.3" + "react-scripts": "0.8.5" }, "dependencies": { "babel-polyfill": "^6.20.0", "immutable": "^3.8.1", - "react": "^15.4.1", - "react-dom": "^15.4.1", - "react-redux": "^5.0.1", - "react-router": "^3.0.0", + "react": "^15.4.2", + "react-dom": "^15.4.2", + "react-redux": "^5.0.2", + "react-router": "^3.0.2", "react-router-redux": "^4.0.7", "rebass": "^0.3.3", "redux": "^3.6.0", - "redux-saga": "^0.13.0", + "redux-saga": "^0.14.3", + "redux-saga-router": "^1.1.0", "reflexbox": "^2.2.3", "sockjs-client": "latest", "webstomp-client": "^1.0.3" 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} /> + Take me somewhere ) } 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 } } diff --git a/frontend/yarn.lock b/frontend/yarn.lock index cee03120..6731c3d3 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -275,13 +275,14 @@ babel-core@^6.18.0: slash "^1.0.0" source-map "^0.5.0" -babel-eslint@7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.0.0.tgz#54e51b4033f54ac81326ecea4c646a779935196d" +babel-eslint@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.1.1.tgz#8a6a884f085aa7060af69cfc77341c2f99370fb2" dependencies: + babel-code-frame "^6.16.0" babel-traverse "^6.15.0" babel-types "^6.15.0" - babylon "^6.11.2" + babylon "^6.13.0" lodash.pickby "^4.6.0" babel-generator@^6.17.0, babel-generator@^6.18.0: @@ -924,7 +925,7 @@ babel-types@^6.15.0, babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19 lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0, babylon@^6.11.2, babylon@^6.13.0: +babylon@^6.11.0, babylon@^6.13.0: version "6.14.1" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.14.1.tgz#956275fab72753ad9b3435d7afe58f8bf0a29815" @@ -2197,6 +2198,10 @@ fsevents@1.0.14, fsevents@^1.0.0: nan "^2.3.0" node-pre-gyp "^0.6.29" +fsm-iterator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fsm-iterator/-/fsm-iterator-1.0.0.tgz#b82821315d6d5d0f44c9f3228f41851b59dc45c6" + fstream-ignore@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" @@ -2380,6 +2385,16 @@ history@^3.0.0: query-string "^4.2.2" warning "^3.0.0" +history@^4.3.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/history/-/history-4.5.1.tgz#44935a51021e3b8e67ebac267a35675732aba569" + dependencies: + invariant "^2.2.1" + loose-envify "^1.2.0" + resolve-pathname "^2.0.0" + value-equal "^0.2.0" + warning "^3.0.0" + hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" @@ -4193,9 +4208,9 @@ react-addons-pure-render-mixin@^15.3.1: version "15.4.1" resolved "https://registry.yarnpkg.com/react-addons-pure-render-mixin/-/react-addons-pure-render-mixin-15.4.1.tgz#8a1f48f9fd3f24ed12af63c4d2dc0c7529fa7e02" -react-dev-utils@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-0.4.1.tgz#06385e3c15014d4dfa0a6134bfeeeb0700cc04dd" +react-dev-utils@^0.4.2: + version "0.4.2" + resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-0.4.2.tgz#ba6fae581fe945a2fc402e9b27c71fda4f62f6a1" dependencies: ansi-html "0.0.5" chalk "1.1.3" @@ -4205,9 +4220,9 @@ react-dev-utils@^0.4.1: sockjs-client "1.0.3" strip-ansi "3.0.1" -react-dom@^15.4.1: - version "15.4.1" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.4.1.tgz#d54c913261aaedb17adc20410d029dcc18a1344a" +react-dom@^15.4.2: + version "15.4.2" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.4.2.tgz#015363f05b0a1fd52ae9efdd3a0060d90695208f" dependencies: fbjs "^0.8.1" loose-envify "^1.1.0" @@ -4227,9 +4242,9 @@ react-router-redux@^4.0.7: version "4.0.7" resolved "https://registry.yarnpkg.com/react-router-redux/-/react-router-redux-4.0.7.tgz#9b1fde4e70106c50f47214e12bdd888cfb96e2a6" -react-router@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-3.0.0.tgz#3f313e4dbaf57048c48dd0a8c3cac24d93667dff" +react-router@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-3.0.2.tgz#5a19156678810e01d81901f9c0fef63284b8a514" dependencies: history "^3.0.0" hoist-non-react-statics "^1.2.0" @@ -4237,13 +4252,13 @@ react-router@^3.0.0: loose-envify "^1.2.0" warning "^3.0.0" -react-scripts@0.8.3: - version "0.8.3" - resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-0.8.3.tgz#96c7d45f57eca5f00415c53fda27ef9a36566580" +react-scripts@0.8.5: + version "0.8.5" + resolved "https://registry.yarnpkg.com/react-scripts/-/react-scripts-0.8.5.tgz#5dc154617be7addef5022c261b96b3e3068418cb" dependencies: autoprefixer "6.5.1" babel-core "6.17.0" - babel-eslint "7.0.0" + babel-eslint "7.1.1" babel-jest "17.0.2" babel-loader "6.2.7" babel-preset-react-app "^2.0.1" @@ -4274,7 +4289,7 @@ react-scripts@0.8.3: path-exists "2.1.0" postcss-loader "1.0.0" promise "7.1.1" - react-dev-utils "^0.4.1" + react-dev-utils "^0.4.2" recursive-readdir "2.1.0" strip-ansi "3.0.1" style-loader "0.13.1" @@ -4282,14 +4297,13 @@ react-scripts@0.8.3: webpack "1.14.0" webpack-dev-server "1.16.2" webpack-manifest-plugin "1.1.0" - webpack-subresource-integrity "0.8.1" whatwg-fetch "1.0.0" optionalDependencies: fsevents "1.0.14" -react@^15.4.1: - version "15.4.1" - resolved "https://registry.yarnpkg.com/react/-/react-15.4.1.tgz#498e918602677a3983cd0fd206dfe700389a0dd6" +react@^15.4.2: + version "15.4.2" + resolved "https://registry.yarnpkg.com/react/-/react-15.4.2.tgz#41f7991b26185392ba9bae96c8889e7e018397ef" dependencies: fbjs "^0.8.4" loose-envify "^1.1.0" @@ -4406,6 +4420,14 @@ redux-saga: version "0.13.0" resolved "https://registry.yarnpkg.com/redux-saga/-/redux-saga-0.13.0.tgz#9294386550deb0d56bc9a1b3c90a613e7ddb6593" +redux-saga-router@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/redux-saga-router/-/redux-saga-router-1.1.0.tgz#c2edf4445c9def382fd64d3e8f63c7f4d519bb91" + dependencies: + fsm-iterator "^1.0.0" + history "^4.3.0" + ruta3 "^2.0.1" + reflexbox: version "2.2.3" resolved "https://registry.yarnpkg.com/reflexbox/-/reflexbox-2.2.3.tgz#9b9ce983dbe677cebf3a94cf2c50b8157f50c0d1" @@ -4538,6 +4560,10 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" +resolve-pathname@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.0.2.tgz#e55c016eb2e9df1de98e85002282bfb38c630436" + resolve@1.1.7, resolve@1.1.x, resolve@^1.1.6: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" @@ -4581,6 +4607,10 @@ run-async@^0.1.0: dependencies: once "^1.3.0" +ruta3@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ruta3/-/ruta3-2.0.1.tgz#b40efa789e6cfce0abf3a5a38bf64cb45abdc18e" + rx-lite@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" @@ -5146,6 +5176,10 @@ validate-npm-package-license@^3.0.1: spdx-correct "~1.0.0" spdx-expression-parse "~1.0.0" +value-equal@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.2.0.tgz#4f41c60a3fc011139a2ec3d3340a8998ae8b69c0" + vary@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.0.tgz#e1e5affbbd16ae768dd2674394b9ad3022653140" @@ -5194,7 +5228,7 @@ webidl-conversions@^3.0.0, webidl-conversions@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" -webpack-core@^0.6.8, webpack-core@~0.6.9: +webpack-core@~0.6.9: version "0.6.9" resolved "https://registry.yarnpkg.com/webpack-core/-/webpack-core-0.6.9.tgz#fc571588c8558da77be9efb6debdc5a3b172bdc2" dependencies: @@ -5242,12 +5276,6 @@ webpack-sources@^0.1.0: source-list-map "~0.1.0" source-map "~0.5.3" -webpack-subresource-integrity@0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/webpack-subresource-integrity/-/webpack-subresource-integrity-0.8.1.tgz#51f290f5996ee94cd1f518198a9b421a17d2191e" - dependencies: - webpack-core "^0.6.8" - webpack@1.14.0: version "1.14.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.14.0.tgz#54f1ffb92051a328a5b2057d6ae33c289462c823" -- cgit