We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b575016 commit 8707973Copy full SHA for 8707973
src/createMiddleware.js
@@ -1,16 +1,10 @@
1
-import mapValues from 'lodash.mapvalues'
2
-
3
export default function createMiddleware(actionHandlers) {
4
- const result = store => {
5
- const handlersForStore = mapValues(actionHandlers, handler => handler(store))
6
- return next => {
7
- const handlersForNext = mapValues(handlersForStore, handler => handler(next))
8
- return action => {
9
- const handler = handlersForNext[action.type]
10
- return handler ? handler(action) : next(action)
11
- }
12
+ const result = store => next => action => {
+ const handler = actionHandlers[action.type]
+ if (!handler) return next(action)
+ return handler(store)(next)(action)
13
}
14
result.actionHandlers = actionHandlers
15
return result
16
+
0 commit comments