Skip to content

Return the result of dispatch call to store #38

Open
@effervescentia

Description

@effervescentia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions