-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
240 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import TraderCTA from './TraderCTA'; | ||
import StocksTable from './StocksTable'; | ||
import './style.scss'; | ||
|
||
export default function StockApp() { | ||
return ( | ||
<div> | ||
<p>Synape Demo Page for Stock Application (In Progress)</p> | ||
<TraderCTA /> | ||
<StocksTable /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
export default class StocksTable extends React.Component { | ||
static propTypes = { | ||
stocks: PropTypes.any.isRequired, | ||
addStock: PropTypes.func.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
renderStocks = () => { | ||
return this.props.stocks.map((p, i) => { | ||
return ( | ||
<p key={i}>{p.name}</p> | ||
); | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h2>Stocks Table</h2> | ||
{this.renderStocks()} | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const mapStateToProps = (state) => { | ||
return { | ||
stocks: state.stocks.allStocks, | ||
}; | ||
}; | ||
|
||
export const mapDispatchToProps = (dispatch) => { | ||
return { | ||
addStock: (name, currentValue, previousValue) => dispatch({ | ||
type: 'ADD_STOCK', | ||
name, | ||
currentValue, | ||
previousValue, | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { synapse } from 'redux-synapse'; | ||
import StocksTable from './StocksTable'; | ||
import { mapStateToProps, mapDispatchToProps } from './StocksTableContainer'; | ||
|
||
export default synapse(mapStateToProps, mapDispatchToProps, ['stocks'])(StocksTable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { PropTypes } from 'react'; | ||
|
||
export default class TraderCTA extends React.Component { | ||
static propTypes = { | ||
name: PropTypes.string.isRequired, | ||
setName: PropTypes.func.isRequired, | ||
setAccountValue: PropTypes.func.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
name: props.name, | ||
}; | ||
} | ||
|
||
handleChange = (e) => { | ||
this.setState({ | ||
name: e.target.value, | ||
}); | ||
} | ||
|
||
handleClick = () => { | ||
this.props.setName(this.state.name); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<input type="text" onChange={this.handleChange} value={this.state.name} /> | ||
<button onClick={this.handleClick}>Set Name</button> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const mapStateToProps = (state) => { | ||
return { | ||
name: state.trader.name, | ||
accountValue: state.trader.accountValue, | ||
}; | ||
}; | ||
|
||
export const mapDispatchToProps = (dispatch) => { | ||
return { | ||
setName: (name) => dispatch({ | ||
type: 'SET_TRADER_NAME', | ||
name, | ||
}), | ||
setAccountValue: () => {}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { synapse } from 'redux-synapse'; | ||
import TraderCTA from './TraderCTA'; | ||
import { mapStateToProps, mapDispatchToProps } from './TraderCTAContainer'; | ||
|
||
export default synapse(mapStateToProps, mapDispatchToProps, ['trader'])(TraderCTA); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$font-stack: Helvetica, sans-serif; | ||
$primary-color: red; | ||
|
||
body { | ||
font: 100% $font-stack; | ||
color: $primary-color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Synapse Todo Demo</title> | ||
<title>Synapse Demo</title> | ||
<meta charset="utf-8"/> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<h1>Loading Synapse Demo...</h1> | ||
<h1>=Loading=</h1> | ||
</div> | ||
<script src="./dist/bundle.js" ></script> | ||
<script src="./dist/app.bundle.js" ></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Record, List } from 'immutable'; | ||
|
||
export default Record({ | ||
name: '', | ||
currentValue: 0, | ||
previousValue: 0, | ||
valueDifference: 0, | ||
bidHistory: List(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Record, List } from 'immutable'; | ||
|
||
const OptionsRecord = Record({ | ||
updateSpeedMs: 2500, | ||
}); | ||
|
||
export default Record({ | ||
stockTotalValue: 0, | ||
allStocks: List(), | ||
options: new OptionsRecord(), | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Record } from 'immutable'; | ||
|
||
export default Record({ | ||
name: 'NONE_SET', | ||
accountValue: 0, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import trader from './traderReducer'; | ||
import stocks from './stockSReducer'; | ||
|
||
export default { | ||
trader, | ||
stocks, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import StocksRecord from '../records/StocksRecord'; | ||
import StockRecord from '../records/StockRecord'; | ||
import { List } from 'immutable'; | ||
|
||
const defaultState = new StocksRecord({ | ||
allStocks: List([ | ||
new StockRecord({ | ||
name: 'FTSE', | ||
currentValue: 1000, | ||
previousValue: 750, | ||
valueDifference: 250, | ||
bidHistory: List([ | ||
0, | ||
]), | ||
}), | ||
]), | ||
}); | ||
|
||
const stock = (state = defaultState, action) => { | ||
let newState; | ||
switch (action.type) { | ||
case 'SET_UPDATE_SPEED': | ||
newState = state.setIn(['options', 'updateSpeedMs'], action.updateSpeedMs); | ||
prepareNotification(['stock-options']); | ||
return newState; | ||
case 'ADD_STOCK': | ||
let allStocks = state.allStocks; | ||
allStocks = allStocks.push(new StockRecord(action.stock)); | ||
newState = state.set('allStocks', allStocks); | ||
prepareNotification(['stocks']); | ||
return newState; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default stock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import TraderRecord from '../records/TraderRecord'; | ||
import { prepareNotification } from 'redux-synapse'; | ||
|
||
const trader = (state = new TraderRecord(), action) => { | ||
let newState; | ||
switch (action.type) { | ||
case 'SET_TRADER_VALUE': | ||
newState = state.set('accountValue', action.accountValue); | ||
prepareNotification(['trader']); | ||
return newState; | ||
case 'SET_TRADER_NAME': | ||
newState = state.set('name', action.name); | ||
prepareNotification(['trader']); | ||
return newState; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default trader; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "redux-synapse", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"src", | ||
|
@@ -22,7 +22,7 @@ | |
"watch:demo": "webpack --watch ./demo --config ./demo/webpack.config.js", | ||
"lint": "eslint ./src", | ||
"test": "jest", | ||
"test:tc": "jest --runInBand", | ||
"test:tc": "jest --runInBand" | ||
}, | ||
"author": "Jon Evans ([email protected])", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters