redux
redux copied to clipboard
Return the result of dispatch call to store
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @logux/[email protected]
for the project I'm working on.
I'm trying to add support for dispatching thunks to our logux store on the client side. My approach has been to use redux-thunk-fsa
so that all thunks have a type
and the callback is passed as the payload
. However in order for my components to access the results of the executed thunks requires returning the result of the dispatch operation.
Here is the diff that solved my problem:
diff --git a/node_modules/@logux/redux/create-store-creator/index.js b/node_modules/@logux/redux/create-store-creator/index.js
index 2d77ee5..b97b2cd 100644
--- a/node_modules/@logux/redux/create-store-creator/index.js
+++ b/node_modules/@logux/redux/create-store-creator/index.js
@@ -64,9 +64,10 @@ export function createStoreCreator(client, options = {}) {
prevMeta = meta
let prevState = store.getState()
- originDispatch(action)
+ let result = originDispatch(action)
emitter.emit('change', store.getState(), prevState, action, meta)
saveHistory(meta)
+ return result
}
store.dispatch.local = (action, meta = {}) => {
This issue body was partially generated by patch-package.
Let’s use it in main
. Please send PR, I will release it.