react-hook-thunk-reducer
react-hook-thunk-reducer copied to clipboard
Support injecting a custom argument
Redux-thunk has a feature where you can inject a custom argument.
I think this library can support the same feature if it were implemented like so:
helpers/useThunkReducer.js
import { withExtraArgument } from 'react-hook-thunk-reducer';
import BrowserApp from '../BrowserApp';
export default withExtraArgument({ app: new BrowserApp() });
An implementation of this might look like thus:
const saveData = (dispatch, getState, { app }) => {
app.localStorage.setItem('data', JSON.stringify(data));
};
Hey @jedmao, thanks for the suggestion! I remember seeing this when I was building out this module and using redux thunk as a reference. However, for the first release I wanted to keep things simple. I'll certainly consider adding this in in future :)
PRs are also welcome!
If no one's working on it. Can I create a PR?
I've experimented with this and I didn't find a solution I was totally happy with. It would be very helpful to see other approaches and maybe we can work together for a common solution (: definitely give it a shot
You might also consider the solution described in #10