Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pengxingjian.pxj committed Sep 6, 2017
1 parent 0a0a1d1 commit 475a141
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion examples/counter-immutable/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Counter example work with ImmutableJS for mickey", "description": "Counter example work with ImmutableJS for mickey",
"dependencies": { "dependencies": {
"immutable": "^3.8.1", "immutable": "^3.8.1",
"mickey": "^0.2.2", "mickey": "^0.2.4",
"react": "^15.6.1", "react": "^15.6.1",
"redux-immutablejs": "^0.0.8" "redux-immutablejs": "^0.0.8"
}, },
Expand Down
18 changes: 10 additions & 8 deletions examples/counter-immutable/src/App.jsx
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */


import React from 'react' import React from 'react'
import { actions, connect } from 'mickey' import { connect, injectActions } from 'mickey'
import './App.css' import './App.css'


const App = props => ( const App = props => (
<div id="counter-app"> <div id="counter-app">
<h1>{props.count}</h1> <h1>{props.count}</h1>
<div className="btn-wrap"> <div className="btn-wrap">
<button onClick={() => actions.counter.decrement()}>-</button> <button onClick={() => props.actions.counter.decrement()}>-</button>
<button onClick={() => actions.counter.increment()}>+</button> <button onClick={() => props.actions.counter.increment()}>+</button>
<button <button
style={{ width: 100 }} style={{ width: 100 }}
onClick={() => { onClick={() => {
if (props.loading) { if (props.loading) {
alert('loading') // eslint-disable-line alert('loading') // eslint-disable-line
} else { } else {
actions.counter.incrementAsync() props.actions.counter.incrementAsync()
} }
}} }}
> >
Expand All @@ -26,7 +26,9 @@ const App = props => (
</div> </div>
) )


export default connect((store) => { export default injectActions(
console.log('data:', store.get('counter').toJS()) // eslint-disable-line connect((store) => {
return ({ ...store.get('counter').toJS() }) console.log('data:', store.get('counter').toJS()) // eslint-disable-line
})(App) return ({ ...store.get('counter').toJS() })
})(App),
)
2 changes: 1 addition & 1 deletion examples/counter-persist-immutable/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Counter example work with persist and immutable for mickey", "description": "Counter example work with persist and immutable for mickey",
"dependencies": { "dependencies": {
"immutable": "^3.8.1", "immutable": "^3.8.1",
"mickey": "^0.2.2", "mickey": "^0.2.4",
"react": "^15.6.1", "react": "^15.6.1",
"redux-action-buffer": "^1.1.0", "redux-action-buffer": "^1.1.0",
"redux-immutablejs": "^0.0.8", "redux-immutablejs": "^0.0.8",
Expand Down
18 changes: 10 additions & 8 deletions examples/counter-persist-immutable/src/App.jsx
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */


import React from 'react' import React from 'react'
import { actions, connect } from 'mickey' import { injectActions, connect } from 'mickey'
import './App.css' import './App.css'


const App = props => ( const App = props => (
<div id="counter-app"> <div id="counter-app">
<h1>{props.count}</h1> <h1>{props.count}</h1>
<div className="btn-wrap"> <div className="btn-wrap">
<button onClick={() => actions.counter.decrement()}>-</button> <button onClick={() => props.actions.counter.decrement()}>-</button>
<button onClick={() => actions.counter.increment()}>+</button> <button onClick={() => props.actions.counter.increment()}>+</button>
<button <button
style={{ width: 100 }} style={{ width: 100 }}
onClick={() => { onClick={() => {
if (props.loading) { if (props.loading) {
alert('loading') // eslint-disable-line alert('loading') // eslint-disable-line
} else { } else {
actions.counter.incrementAsync() props.actions.counter.incrementAsync()
} }
}} }}
> >
Expand All @@ -27,7 +27,9 @@ const App = props => (
</div> </div>
) )


export default connect((store) => { export default injectActions(
console.log('data:', store.get('counter').toJS()) // eslint-disable-line connect((store) => {
return ({ ...store.get('counter').toJS() }) console.log('data:', store.get('counter').toJS()) // eslint-disable-line
})(App) return ({ ...store.get('counter').toJS() })
})(App),
)
2 changes: 1 addition & 1 deletion examples/counter-persist/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "counter-persist", "name": "counter-persist",
"description": "Counter example work with redux-persist for mickey", "description": "Counter example work with redux-persist for mickey",
"dependencies": { "dependencies": {
"mickey": "^0.2.2", "mickey": "^0.2.4",
"react": "^15.6.1", "react": "^15.6.1",
"redux-action-buffer": "^1.1.0", "redux-action-buffer": "^1.1.0",
"redux-persist": "^4.9.1" "redux-persist": "^4.9.1"
Expand Down
12 changes: 7 additions & 5 deletions examples/counter-persist/src/App.jsx
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */


import React from 'react' import React from 'react'
import { actions, connect } from 'mickey' import { connect, injectActions } from 'mickey'
import './App.css' import './App.css'


const App = props => ( const App = props => (
<div id="counter-app"> <div id="counter-app">
<h1>{props.count}</h1> <h1>{props.count}</h1>
<div className="btn-wrap"> <div className="btn-wrap">
<button onClick={() => actions.counter.decrement()}>-</button> <button onClick={() => props.actions.counter.decrement()}>-</button>
<button onClick={() => actions.counter.increment()}>+</button> <button onClick={() => props.actions.counter.increment()}>+</button>
<button <button
style={{ width: 100 }} style={{ width: 100 }}
onClick={() => { onClick={() => {
if (props.loading) { if (props.loading) {
alert('loading') // eslint-disable-line alert('loading') // eslint-disable-line
} else { } else {
actions.counter.incrementAsync() props.actions.counter.incrementAsync()
} }
}} }}
> >
Expand All @@ -27,4 +27,6 @@ const App = props => (
</div> </div>
) )


export default connect(store => ({ ...store.counter }))(App) export default injectActions(
connect(store => ({ ...store.counter }))(App),
)
2 changes: 1 addition & 1 deletion examples/counter-undo/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "counter-undo", "name": "counter-undo",
"description": "Counter example work with redux-undo for mickey", "description": "Counter example work with redux-undo for mickey",
"dependencies": { "dependencies": {
"mickey": "^0.2.2", "mickey": "^0.2.4",
"react": "^15.6.1", "react": "^15.6.1",
"redux-undo": "^1.0.0-beta9-9-6" "redux-undo": "^1.0.0-beta9-9-6"
}, },
Expand Down
18 changes: 10 additions & 8 deletions examples/counter-undo/src/App.jsx
Original file line number Original file line Diff line number Diff line change
@@ -1,23 +1,23 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */


import React from 'react' import React from 'react'
import { actions, connect } from 'mickey' import { injectActions, connect } from 'mickey'
import { ActionCreators } from 'redux-undo' import { ActionCreators } from 'redux-undo'
import './App.css' import './App.css'


const App = props => ( const App = props => (
<div id="counter-app"> <div id="counter-app">
<h1>{props.count}</h1> <h1>{props.count}</h1>
<div className="btn-wrap"> <div className="btn-wrap">
<button onClick={() => actions.counter.decrement()}>-</button> <button onClick={() => props.actions.counter.decrement()}>-</button>
<button onClick={() => actions.counter.increment()}>+</button> <button onClick={() => props.actions.counter.increment()}>+</button>
<button <button
style={{ width: 100 }} style={{ width: 100 }}
onClick={() => { onClick={() => {
if (props.loading) { if (props.loading) {
alert('loading') // eslint-disable-line alert('loading') // eslint-disable-line
} else { } else {
actions.counter.incrementAsync() props.actions.counter.incrementAsync()
} }
}} }}
> >
Expand All @@ -29,7 +29,9 @@ const App = props => (
</div> </div>
) )


export default connect((store) => { export default injectActions(
console.log('data:', store.counter) connect((store) => {
return { ...store.counter.present } console.log('data:', store.counter)
})(App) return { ...store.counter.present }
})(App),
)
2 changes: 1 addition & 1 deletion examples/counter/package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "counter", "name": "counter",
"description": "Counter example for mickey", "description": "Counter example for mickey",
"dependencies": { "dependencies": {
"mickey": "^0.2.2", "mickey": "^0.2.4",
"react": "^15.6.1" "react": "^15.6.1"
}, },
"devDependencies": { "devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions examples/counter/src/App.jsx
Original file line number Original file line Diff line number Diff line change
@@ -1,22 +1,22 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */


import React from 'react' import React from 'react'
import { actions, connect } from 'mickey' import { connect, injectActions } from 'mickey'
import './App.css' import './App.css'


const App = props => ( const App = props => (
<div id="counter-app"> <div id="counter-app">
<h1>{props.count}</h1> <h1>{props.count}</h1>
<div className="btn-wrap"> <div className="btn-wrap">
<button onClick={() => actions.counter.decrement()}>-</button> <button onClick={() => props.actions.counter.decrement()}>-</button>
<button onClick={() => actions.counter.increment()}>+</button> <button onClick={() => props.actions.counter.increment()}>+</button>
<button <button
style={{ width: 100 }} style={{ width: 100 }}
onClick={() => { onClick={() => {
if (props.loading) { if (props.loading) {
alert('loading') // eslint-disable-line alert('loading') // eslint-disable-line
} else { } else {
actions.counter.incrementAsync() props.actions.counter.incrementAsync()
} }
}} }}
> >
Expand All @@ -26,4 +26,4 @@ const App = props => (
</div> </div>
) )


export default connect(store => ({ ...store.counter }))(App) export default injectActions(connect(store => ({ ...store.counter }))(App))

0 comments on commit 475a141

Please sign in to comment.