From bbf3c187c4967509a8097b168533786daacc2ec6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 21 May 2018 11:17:31 +0200 Subject: rpc --- app/client/live/actions.js | 23 +++-- app/client/live/index.js | 213 ++++++++++++++++++++++++--------------------- app/client/live/reducer.js | 6 +- 3 files changed, 129 insertions(+), 113 deletions(-) (limited to 'app/client/live') diff --git a/app/client/live/actions.js b/app/client/live/actions.js index 30a25ff..047e51f 100644 --- a/app/client/live/actions.js +++ b/app/client/live/actions.js @@ -1,10 +1,15 @@ -import socket from '../socket' +import * as socket from '../socket' -export const loadOptFromServer = (opt) => ({ - type: 'LIVE_LOAD_OPT_FROM_SERVER', opt, -}) -// export const updateOptFromServer = (key, value) => { -// return { -// type: 'LIVE_LOAD_OPT_FROM_SERVER', opt, -// } -// } +export const get_params = () => { + socket.get_params() + return { type: 'GET_PARAMS', } +} + +export const set_param = (key, value) => { + socket.set_param(key, value) + return { type: 'SET_PARAM', key, value, } +} + +export const get_checkpoints = () => { + return { type: 'GET_CHECKPOINTS', } +} diff --git a/app/client/live/index.js b/app/client/live/index.js index 80f531a..8d16785 100644 --- a/app/client/live/index.js +++ b/app/client/live/index.js @@ -1,126 +1,137 @@ import { h, Component } from 'preact' +import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import Player from './components/player.component' import ParamGroup from '../common/paramGroup.component' import Slider from '../common/slider.component' -function App(props) { - return ( -
- -
+import * as liveActions from './actions' - - - - - +class App extends Component { + constructor(props){ + super() + props.actions.get_params() + } + render(){ + const props = this.props + return ( +
+ +
- - - - - + + + + + - - - - + + + + + - - - + + + + - - - - + + + - - - - + + + + - - - - + + + + + + + + + +
-
- ) + ) + } } const mapStateToProps = state => ({ }) const mapDispatchToProps = (dispatch, ownProps) => ({ + actions: bindActionCreators(liveActions, dispatch) }) export default connect(mapStateToProps, mapDispatchToProps)(App) diff --git a/app/client/live/reducer.js b/app/client/live/reducer.js index 9d41c6f..09a00b5 100644 --- a/app/client/live/reducer.js +++ b/app/client/live/reducer.js @@ -8,9 +8,9 @@ const liveInitialState = { const liveReducer = (state = liveInitialState, action) => { let results; - + console.log(action.type) switch(action.type) { - case 'LIVE_LOAD_OPT_FROM_SERVER': + case 'LOAD_PARAMS': return { ...state, loading: false, @@ -18,7 +18,7 @@ const liveReducer = (state = liveInitialState, action) => { opt: action.opt, } - case 'LIVE_SET_OPT': + case 'SET_PARAM': return { ...state, opt: { -- cgit v1.2.3-70-g09d2