store icon indicating copy to clipboard operation
store copied to clipboard

Thunk when using subStore

Open bunsenbeaker opened this issue 7 years ago • 4 comments

This is a...

  • [ ] feature request
  • [ ] bug report
  • [ *] usage question

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version: Typescript Version: Angular Version: @angular-redux/store version: @angular/cli version: (if applicable) OS:

Link to repo showing the issus

(optional, but helps a lot)

Expected Behaviour:

Actual Behaviour:

Stack Trace/Error Message:

Additional Notes:

(optional) Working with Ang4, I'm using redux-thunk when configuring store. When I'm configuring a subStore in a component, I cannot dispatch thunks (getting an error claiming my Action doesn't have a type). When dispatching plain actions - these are properly dispatched, and my local reducer is hit. Isn't thunk supported for subStores?

bunsenbeaker avatar Nov 14 '17 18:11 bunsenbeaker

Haven't used thunk in a while, but since redux middleware provides the dispatch to the thunk, I could see how this could cause problems.

I'll need to dig a little deeper, but my initial thought is that substores and thunks might not be compatible - at least at this time, but might be possible to fix it.

The issue is, under the hood of subStore.dispatch, it's adding some extra-data to the dispatched action: substore.dispatch

dispatch: Dispatch<State> = action =>
    this.rootStore.dispatch(
      Object.assign({},
      action,
      { '@angular-redux::fractalkey': JSON.stringify(this.basePath) }))

If your action creator is returning a thunk, it's trying to convert that into an object to add some extra data, and probably why you are getting the 'action does not have a type' - as the end result ends up being an object with only the 'angular-redux::fractalkey' on it.

It might be possible to fix this, although not sure when I'll be able to implement/test it.

e-schultz avatar Nov 14 '17 19:11 e-schultz

Any plans?

iwnow avatar Jan 16 '18 22:01 iwnow

bump

desaroxx avatar Mar 20 '18 15:03 desaroxx

Hi,

I have not had time to look into issues much lately and see if anyone at work - or in the community has the time/capacity to help take on some of the maintenance duties.

Have had a few things in my personal life that need focus and attention, which is eating into my time to be able to support this.

If there is anyone that is interested in joining the project as a maintainer, please reach out and let me know.

e-schultz avatar Mar 20 '18 15:03 e-schultz