Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the result of dispatch call to store #38

Open
effervescentia opened this issue Sep 2, 2021 · 1 comment
Open

Return the result of dispatch call to store #38

effervescentia opened this issue Sep 2, 2021 · 1 comment

Comments

@effervescentia
Copy link
Contributor

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.

@ai
Copy link
Member

ai commented Sep 2, 2021

Let’s use it in main. Please send PR, I will release it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants