Skip to content
Permalink
Browse files
Autodux
  • Loading branch information
imjoehaines committed Mar 20, 2018
1 parent d4a179f commit f4d9f8c80d39d3da9c88506e8b54c2d65d88915f
Showing with 42 additions and 46 deletions.
  1. +1 −0 package.json
  2. +4 −3 src/Email/container.js
  3. +4 −5 src/EmailForm/container.js
  4. +2 −1 src/Username/container.js
  5. +4 −5 src/UsernameForm/container.js
  6. +17 −32 src/ducks/index.js
  7. +10 −0 yarn.lock
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"autodux": "^3.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.7",
@@ -1,9 +1,10 @@
import { connect } from 'react-redux'

import Username from './component'
import Email from './component'
import { getEmail } from '../ducks'

export default connect(
state => ({
email: state.email
email: getEmail(state)
})
)(Username)
)(Email)
@@ -1,14 +1,13 @@
import { connect } from 'react-redux'

import Email from './component'

import { setEmail } from '../ducks'
import EmailForm from './component'
import { setEmail, getEmail } from '../ducks'

export default connect(
state => ({
email: state.email
email: getEmail(state)
}),
dispatch => ({
handleEmailChange: event => dispatch(setEmail(event.target.value))
})
)(Email)
)(EmailForm)
@@ -1,9 +1,10 @@
import { connect } from 'react-redux'

import Username from './component'
import { getUsername } from '../ducks'

export default connect(
state => ({
username: state.username
username: getUsername(state)
})
)(Username)
@@ -1,14 +1,13 @@
import { connect } from 'react-redux'

import Username from './component'

import { setUsername } from '../ducks'
import UsernameForm from './component'
import { setUsername, getUsername } from '../ducks'

export default connect(
state => ({
username: state.username
username: getUsername(state)
}),
dispatch => ({
handleUsernameChange: event => dispatch(setUsername(event.target.value))
})
)(Username)
)(UsernameForm)
@@ -1,37 +1,22 @@
const initialState = {
username: 'Anonymous',
email: 'anonymous@example.com'
}
import autodux from 'autodux'

export default (state = initialState, { type, payload }) => {
switch (type) {
case SET_USERNAME:
return {
...state,
username: payload
}

case SET_EMAIL:
return {
...state,
email: payload
}

default:
return state
const {
reducer,
actions: {
setUsername,
setEmail
},
selectors: {
getUsername,
getEmail
}
} = autodux({
initial: {
username: 'Anonymous',
email: 'anonymous@example.com'
}
}

const SET_USERNAME = 'SET_USERNAME'

export const setUsername = username => ({
type: SET_USERNAME,
payload: username
})

const SET_EMAIL = 'SET_EMAIL'
export default reducer

export const setEmail = email => ({
type: SET_EMAIL,
payload: email
})
export { setUsername, setEmail, getUsername, getEmail }
@@ -314,6 +314,12 @@ atob@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d"

autodux@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/autodux/-/autodux-3.0.0.tgz#374a68c3581eabe4573f446b5288179be0bd8b06"
dependencies:
lodash.curry "4.1.1"

autoprefixer@7.1.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.6.tgz#fb933039f74af74a83e71225ce78d9fd58ba84d7"
@@ -4272,6 +4278,10 @@ lodash.cond@^4.3.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"

lodash.curry@4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.curry/-/lodash.curry-4.1.1.tgz#248e36072ede906501d75966200a86dab8b23170"

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"

0 comments on commit f4d9f8c

Please sign in to comment.