-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
57e8305
commit 37c1f24
Showing
21 changed files
with
182 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
src/dist/public | ||
src/server/logs | ||
src/server/logs | ||
logs |
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
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,4 +1,8 @@ | ||
import { action } from '../helpers/actionCreator'; | ||
import * as actions from '../constants/index'; | ||
|
||
export const add = text => action(actions.ADD, { text }); | ||
export const add = number => action(actions.ADD, { number }); | ||
|
||
export const sub = number => action(actions.SUB, { number }); | ||
|
||
export const change = number => action(actions.CHANGE, { number }); |
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,35 +1,37 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ReactPlayer from 'react-player'; | ||
|
||
import '../styles/App.scss'; | ||
import { Button, FormControl } from 'react-bootstrap'; | ||
export default class App extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.handleChange = this.handleChange.bind(this); | ||
} | ||
handleChange(e) { | ||
parseInt(e.target.value) ? this.props.change(parseInt(e.target.value)): ''; | ||
} | ||
render() { | ||
return this.props.number == 1 ? ( | ||
<div> | ||
<ReactPlayer | ||
url="https://www.youtube.com/watch?v=ysz5S6PUM-U" | ||
playing | ||
/> | ||
</div> | ||
) : ( | ||
<div className="container"> | ||
{' '} | ||
Welcome{' '} | ||
<input | ||
type="button" | ||
value="Play Me" | ||
onClick={() => this.props.add(1)} | ||
/>{' '} | ||
</div> | ||
return (<div className="container"> | ||
<Button bsStyle="primary" onClick={() => this.props.add(this.props.number)}> | ||
+ | ||
</Button> | ||
<FormControl | ||
type="text" | ||
value={this.props.number} | ||
onChange={this.handleChange} | ||
/> | ||
<Button bsStyle="primary" onClick={() => this.props.sub(this.props.number)}> | ||
- | ||
</Button> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
App.propTypes = { | ||
number: PropTypes.string, | ||
number: PropTypes.number, | ||
add: PropTypes.func, | ||
recipes: PropTypes.array, | ||
sub: PropTypes.func, | ||
change: PropTypes.func, | ||
}; |
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,4 +1,5 @@ | ||
export const INITALIZE_APPLICATION = 'INITALIZE_APPLICATION'; | ||
export const CHANGE = 'CHANGE'; | ||
export const ADD = 'ADD'; | ||
export const SUB = 'SUB'; | ||
export const SAVE = 'SAVE'; | ||
export const START_APPLICATION = 'START_APPLICATION'; | ||
export const ADD_RECIPES = 'ADD_RECIPES'; |
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
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,10 +1,8 @@ | ||
import { combineReducers } from 'redux'; | ||
import add from './add'; | ||
import recipe from './recipe'; | ||
import calc from './calc'; | ||
|
||
const combined = combineReducers({ | ||
add, | ||
recipe, | ||
calc, | ||
}); | ||
|
||
export default combined; |
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
import { put, takeEvery } from 'redux-saga/effects'; | ||
import * as actions from '../constants'; | ||
|
||
function* initalize() { | ||
try { | ||
yield put({ | ||
type: actions.SAVE, | ||
number: 100, | ||
}); | ||
} catch (e) { | ||
yield put({ type: 'INITALIZE_APPLICATION_FAILED', number: null }); | ||
} | ||
} | ||
|
||
export function* initalizeWatcher() { | ||
yield takeEvery(actions.INITALIZE_APPLICATION, initalize); | ||
} | ||
|
||
function* addnumber(action) { | ||
try { | ||
yield put({ type: actions.SAVE, number: action.payload.number + 1 }); | ||
} catch (e) { | ||
yield put({ type: 'ADD_FAILED', message: e.message }); | ||
} | ||
} | ||
|
||
export function* addWatcher() { | ||
yield takeEvery(actions.ADD, addnumber); | ||
} | ||
export default addWatcher; | ||
|
||
|
||
function* changenumber(action) { | ||
try { | ||
yield put({ type: actions.SAVE, number: action.payload.number }); | ||
} catch (e) { | ||
yield put({ type: 'CHANGE_FAILED', message: e.message }); | ||
} | ||
} | ||
|
||
export function* changeWatcher() { | ||
yield takeEvery(actions.CHANGE, changenumber); | ||
} | ||
|
||
|
||
function* subnumber(action) { | ||
try { | ||
yield put({ type: actions.SAVE, number: action.payload.number - 1 }); | ||
} catch (e) { | ||
yield put({ type: 'SUB_FAILED', message: e.message }); | ||
} | ||
} | ||
|
||
export function* subWatcher() { | ||
yield takeEvery(actions.SUB, subnumber); | ||
} |
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,5 @@ | ||
import { all } from 'redux-saga/effects'; | ||
import addWatcher from './add'; | ||
import startWatcher from './start'; | ||
import * as watcher from './calc'; | ||
export default function* rootSaga() { | ||
yield all([addWatcher(), startWatcher()]); | ||
yield all([watcher.addWatcher(), watcher.subWatcher(), watcher.changeWatcher(), watcher.initalizeWatcher()]); | ||
} |
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
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
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,28 @@ | ||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import * as action from '../../../../src/client/actions'; | ||
import * as actions from '../../../../src/client/constants'; | ||
|
||
describe('actions', () => { | ||
it('should trigger the ADD action', () => { | ||
const number = 100; | ||
const response = action.add(number); | ||
|
||
expect(response.type).to.deep.equal(actions.ADD); | ||
expect(response.payload.number).to.deep.equal(100); | ||
}); | ||
it('should trigger the SUB action', () => { | ||
const number = 100; | ||
const response = action.sub(number); | ||
|
||
expect(response.type).to.deep.equal(actions.SUB); | ||
expect(response.payload.number).to.deep.equal(100); | ||
}); | ||
it('should trigger the CHANGE action', () => { | ||
const number = 100; | ||
const response = action.change(number); | ||
|
||
expect(response.type).to.deep.equal(actions.CHANGE); | ||
expect(response.payload.number).to.deep.equal(100); | ||
}); | ||
}); |
Oops, something went wrong.