Permalink
Browse files

Add editorconfig and make the README match it

  • Loading branch information...
developit committed Dec 7, 2017
1 parent 2a2346c commit 32a3c948c1d8a36adf3bae82861ba37dc48efe1a
Showing with 54 additions and 37 deletions.
  1. +17 −0 .editorconfig
  2. +36 −36 README.md
  3. +1 −1 package.json
View
@@ -0,0 +1,17 @@
root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{package.json,.*rc,*.yml}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2
View
@@ -57,48 +57,48 @@ let store = createStore({ count: 0 })
// If actions is a function, it gets passed the store:
let actions = store => ({
// Actions can just return a state update:
increment(state) {
return { count: state.count+1 }
},
// The above example as an Arrow Function:
increment2: ({ count }) => ({ count: count+1 }),
//Actions receive current state as first parameter and any other params next
//check this function as <button onClick={incrementAndLog}>
incrementAndLog: ({ count }, event) => {
console.info(event)
return { count: count+1 }
},
// Async actions can be pure async/promise functions:
async getStuff(state) {
let res = await fetch('/foo.json')
return { stuff: await res.json() }
},
// ... or just actions that call store.setState() later:
incrementAsync(state) {
setTimeout( () => {
store.setState({ count: state.count+1 })
}, 100)
}
// Actions can just return a state update:
increment(state) {
return { count: state.count+1 }
},
// The above example as an Arrow Function:
increment2: ({ count }) => ({ count: count+1 }),
//Actions receive current state as first parameter and any other params next
//check this function as <button onClick={incrementAndLog}>
incrementAndLog: ({ count }, event) => {
console.info(event)
return { count: count+1 }
},
// Async actions can be pure async/promise functions:
async getStuff(state) {
let res = await fetch('/foo.json')
return { stuff: await res.json() }
},
// ... or just actions that call store.setState() later:
incrementAsync(state) {
setTimeout( () => {
store.setState({ count: state.count+1 })
}, 100)
}
})
const App = connect('count', actions)(
({ count, increment }) => (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</div>
)
({ count, increment }) => (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</div>
)
)
export default () => (
<Provider store={store}>
<App />
</Provider>
<Provider store={store}>
<App />
</Provider>
)
```
View
@@ -11,7 +11,7 @@
"build": "npm run -s transpile && npm run -s size && npm run -s docs",
"transpile": "rollup -c --environment FORMAT:umd && rollup -c --environment FORMAT:cjs && rollup -c --environment FORMAT:es",
"size": "strip-json-comments --no-whitespace dist/unistore.js | gzip-size",
"docs": "documentation readme unistore.js -q --section API",
"docs": "documentation readme unistore.js -q --section API && sed -i '' 's/- /- /' README.md",
"test": "eslint unistore.js && jest",
"prepublishOnly": "npm run build"
},

0 comments on commit 32a3c94

Please sign in to comment.