Skip to content

Commit

Permalink
swarmlog enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
philholden committed May 28, 2016
1 parent f1f56f8 commit adc501a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
19 changes: 13 additions & 6 deletions actions/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import * as types from '../constants/ActionTypes'
import keys from '../keys.json'

import {
keyToUriId
} from '@philholden/redux-swarmlog'

const reduxSwarmLogId = keyToUriId(keys.public)

export function addTodo(text) {
return { type: types.ADD_TODO, text }
return { type: types.ADD_TODO, text, reduxSwarmLogId }
}

export function deleteTodo(id) {
return { type: types.DELETE_TODO, id }
return { type: types.DELETE_TODO, id, reduxSwarmLogId }
}

export function editTodo(id, text) {
return { type: types.EDIT_TODO, id, text }
return { type: types.EDIT_TODO, id, text, reduxSwarmLogId }
}

export function completeTodo(id) {
return { type: types.COMPLETE_TODO, id }
return { type: types.COMPLETE_TODO, id, reduxSwarmLogId }
}

export function completeAll() {
return { type: types.COMPLETE_ALL }
return { type: types.COMPLETE_ALL, reduxSwarmLogId }
}

export function clearCompleted() {
return { type: types.CLEAR_COMPLETED }
return { type: types.CLEAR_COMPLETED, reduxSwarmLogId }
}
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import { Provider } from 'react-redux'
import App from './containers/App'
import configureStore from './store/configureStore'
import 'todomvc-app-css/index.css'
import keys from './keys.json'
import {
addReduxSwarmLog,
configureReduxSwarmLog
} from '@philholden/redux-swarmlog'

const store = configureStore()
configureReduxSwarmLog({ reduxStore: store })
addReduxSwarmLog({ name: 'todos', keys })

render(
<Provider store={store}>
Expand Down
6 changes: 6 additions & 0 deletions keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"curve": "ed25519",
"public": "dCsLCEpygCYqdu4XYel2j6Qg4ODY0PXl5Qdd1rjuazM=.ed25519",
"private": "r1d8qGpIGiyBW+3B+CKIR\/BRNXvw6HRK2wes24mXx9V0KwsISnKAJip27hdh6XaPpCDg4NjQ9eXlB13WuO5rMw==.ed25519",
"id": "@dCsLCEpygCYqdu4XYel2j6Qg4ODY0PXl5Qdd1rjuazM=.ed25519"
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"redux": "^3.2.1"
},
"devDependencies": {
"@philholden/redux-swarmlog": "^0.1.0",
"babel-core": "^6.3.15",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
Expand All @@ -35,10 +36,12 @@
"expect": "^1.8.0",
"express": "^4.13.3",
"jsdom": "^5.6.1",
"json-loader": "^0.5.4",
"mocha": "^2.2.5",
"node-libs-browser": "^0.5.2",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^0.14.7",
"ssb-keys": "^5.0.2",
"style-loader": "^0.12.3",
"todomvc-app-css": "^2.0.1",
"webpack": "^1.9.11",
Expand Down
10 changes: 2 additions & 8 deletions reducers/todos.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { ADD_TODO, DELETE_TODO, EDIT_TODO, COMPLETE_TODO, COMPLETE_ALL, CLEAR_COMPLETED } from '../constants/ActionTypes'

const initialState = [
{
text: 'Use Redux',
completed: false,
id: 0
}
]
const initialState = []

export default function todos(state = initialState, action) {
switch (action.type) {
Expand All @@ -16,7 +10,7 @@ export default function todos(state = initialState, action) {
id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1,
completed: false,
text: action.text
},
},
...state
]

Expand Down
16 changes: 14 additions & 2 deletions store/configureStore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import { createStore } from 'redux'
import {
createStore,
applyMiddleware
} from 'redux'

import {
reduxSwarmLogMiddleware
} from '@philholden/redux-swarmlog'

import rootReducer from '../reducers'

export default function configureStore(initialState) {
const store = createStore(rootReducer, initialState)
const store = createStore(
rootReducer,
initialState,
applyMiddleware(reduxSwarmLogMiddleware)
)

if (module.hot) {
// Enable Webpack hot module replacement for reducers
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ module.exports = {
test: /\.css?$/,
loaders: [ 'style', 'raw' ],
include: __dirname
},
{
test: /\.json$/,
loader: require.resolve('json-loader')
}
]
}
Expand Down

0 comments on commit adc501a

Please sign in to comment.