Skip to content

Commit 2e53ecf

Browse files
committed
Merge pull request #7 from zalmoxisus/master
Allow to pass a custom function to be called for dispatching actions
2 parents e258b2d + 6d7b0af commit 2e53ecf

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Name | Description
7979
`theme` | _Same as in LogMonitor's package_ Either a string referring to one of the themes provided by [redux-devtools-themes](https://github.com/gaearon/redux-devtools-themes) (feel free to contribute!) or a custom object of the same format. Optional. By default, set to [`'nicinabox'`](https://github.com/gaearon/redux-devtools-themes/blob/master/src/nicinabox.js).
8080
`initEmpty` | When `true`, the dispatcher is empty. By default, set to `false`, the dispatcher contains : `{ "type": "" }`.
8181
`actionCreators` | Either a array of action creators or an object containing action creators. When defined, a selector appears to choose the action creator you want to fire, you can fill up the arguments and dispatch the action.
82+
`dispatchFn` | Function to be called for dispatching actions. By default it is using component's `this.context.store.dispatch`.
8283

8384
### Contributing
8485

src/Dispatcher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class Dispatcher extends Component {
5252
PropTypes.object,
5353
PropTypes.array,
5454
]),
55+
dispatchFn: PropTypes.func,
5556
theme: PropTypes.oneOfType([
5657
PropTypes.object,
5758
PropTypes.string,
@@ -116,7 +117,7 @@ export default class Dispatcher extends Component {
116117
actionCreator = new Function('return ' + this.refs.action.textContent);
117118
}
118119

119-
this.context.store.dispatch(actionCreator(...argsToInject));
120+
(this.props.dispatchFn || this.context.store.dispatch)(actionCreator(...argsToInject));
120121

121122
this.setState({error: null});
122123
} catch(e) {

0 commit comments

Comments
 (0)