joshburgess / redux-most

Most.js based middleware for Redux. Handle async actions with monadic streams & reactive programming.
https://www.npmjs.com/package/redux-most
MIT License
139 stars 14 forks source link

redux-thunk instead of actions #25

Open goodmind opened 6 years ago

goodmind commented 6 years ago

If used with redux-thunk I got functions in stream instead of dispatched actions. Used same way as in docs with createStateStreamEnhancer

joshburgess commented 6 years ago

@goodmind Can you copy and paste your store setup code here for me to look at? After that, I'll try to replicate it and figure out what's going on.

goodmind commented 6 years ago
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const middlewares = [
   thunk,
]
const storeEnhancers = composeEnhancers(
  createStateStreamEnhancer(epicMiddleware),
  applyMiddleware(...middlewares)
)
const store = createStore(
  combineReducers(reducers),
  storeEnhancers,
)
joshburgess commented 6 years ago

@goodmind Alright, I'm pretty sure I know what the problem is. I'll try to work out a fix soon.

Sorry, I never really intended it to be used in tandem with redux-thunk, but I should be able to make it work.

goodmind commented 6 years ago

@joshburgess btw it's just transition phase from thunks

joshburgess commented 6 years ago

@goodmind Sorry for the long wait. I'm looking into this again now, but still in the process of figuring out how to accomplish it. It involves changing the definition of createStateStreamEnhancer to accept multiple middleware (just like applyMiddleware works..... applyMiddleware is really just an enhancer like anything else), but I'm running into some issues which I believe are due to both epics and thunks being of type function, but I'm still trying to figure it out.

I'll have progress on it in a new branch called redux-thunk-compatibility if you'd like to take a look and help out.