samiskin / redux-electron-store

⎋ A redux store enhancer that allows automatic synchronization between electron processes
MIT License
375 stars 32 forks source link

Default Redux dispatch() return value is being overridden/removed #24

Closed jakereps closed 8 years ago

jakereps commented 8 years ago

The default return value for a Redux dispatch() is the action that was launched by the call. This package is breaking that default behavior, and dispatch() is only returning undefined.

To show a real-world application of this feature, here is a chunk of code from a project that is using the returned actions:

fetchAPI(secretKey, method, url)
.then(json => json.plugins.map(plugin => dispatch(foundPlugin(plugin))))
.then(pluginActions => pluginActions.forEach(
    ({ plugin: { name, methodsURI, visualizersURI } }) => {
        dispatch(loadMethods(name, methodsURI));
        dispatch(loadVisualizers(name, visualizersURI));
    }));

Where the json.plugins.map(dispatch()) was producing a list of the actions that were dispatched and would pass them along to the next step in the chain. After adding redux-electron-store, all that is returned is a list of undefined's.

I tried hooking into the postDispatchCallback() to see if I could pump the action through using one of the available API methods, but it doesn't seem like that will work since telling that callback to return the action will just return it to the doDispatch method body, and not out of the dispatch() call itself.

samiskin commented 8 years ago

Ah good point, I did not know dispatch had a return value, so thanks for bringing it up.

If you could submit a PR to fix this that would be a huge help, since I'm pretty busy for the next week or so. If you don't end up submitting a PR, I'll get to fixing this when I can.

jakereps commented 8 years ago

I can definitely look into it.

Thanks for this awesome package, by the way! It was a huge help with removing ipc "hacks" that threw objects between windows.

samiskin commented 8 years ago

Published in v0.3.11 :+1:, thanks for contributing!

jakereps commented 8 years ago

Awesome! You're welcome! Thank you again, for this awesome package!