The applyMiddleware function in this project is very similar to the one in https://github.com/reduxjs/redux, but the difference is that redux doesn't use classes or rely on this in their store to access the current state, so in that project the method does not need to be properly bound to the store.
When using middleware that exposes getState, an error is occurring when the method is called:
Uncaught (in promise) TypeError: Cannot read property 'state' of undefined
Here is some code that reproduces the issue:
The applyMiddleware function in this project is very similar to the one in https://github.com/reduxjs/redux, but the difference is that redux doesn't use classes or rely on
this
in their store to access the current state, so in that project the method does not need to be properly bound to the store.A fix can be made by changing this line to:
getState: store.getState.bind(store)
I'm planning to work on a PR this weekend to fix this, and also perhaps to tackle #139 as well.