angular-redux / store

Angular 2+ bindings for Redux
MIT License
1.34k stars 202 forks source link

Thunk when using subStore #485

Open bunsenbeaker opened 6 years ago

bunsenbeaker commented 6 years ago

This is a...

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?

e-schultz commented 6 years ago

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.

iwnow commented 6 years ago

Any plans?

desaroxx commented 6 years ago

bump

e-schultz commented 6 years ago

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.