Either CombineEpics typing is misleading or I don't understand something
See original GitHub issueDo you want to request a feature or report a bug?
I want to report a bug.
Here’s the problem. I have a bunch of modules (store/state, actions, reducer, epic(s), views). If I combine reducers like this:
type Module1State = { .... }
...
type Module2State = { .... }
...
type RootState = {
m1: Module1State
m2: Module2State
}
...
const rootReducer: Reducer<RootState> = combineReducers<RootState>({
m1: module1reducer,
m2: module2reducer
});
… I get my RootState
just like it is shown above.
Now, each module has its own Epic:
type Module1Action = ... | ... | ...
type Module1State = { .... }
...
const m1Epic: Epic<Module1Action, Module1State>
Okay. The problem appears when I want to combine such Epics:
import { m1Epic, m1ActionType, m1State } from './m1';
import { m2Epic, m2ActionType, m2State } from './m2';
...
type RootAction = m1ActionType | m2ActionType
type RootState = {
m1: m1State
m2: m2State
}
...
const store = createStore<RootAction>(
rootReducer,
applyMiddleware(
createEpicMiddleware(
combineEpics<RootAction, RootState>(m1Epic, m2Epic)
)
)
);
This will not compile because according to https://github.com/redux-observable/redux-observable/blob/master/index.d.ts#L51 combineEpics
takes type S
for Root State Type. Therefor, RootState
is not assignable to m1State
or m1State
Therefore, it’s either me being stupid and doing something wrong or there’s an issue with the type signatures…
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
redux-observable/redux-observable - Gitter
combineEpics is just a merge. so all yours epics become one big observable. ofType is just a helper function that applies a filter...
Read more >Reducers - TS-React-Boilerplate
Reducers. Now we build our business logic, also known as reducers. Stay calm, this will be a bit more complicated than anything before....
Read more >Redux-Observable's best-practice is an anti-pattern.
I was recently on a project using Redux-Thunk and was astounded by how easy it is to dispatch actions. I get that most...
Read more >Purely Functional React Signup with Redux-Observable ...
In this tutorial, we'll build a signup UI using React/Redux and three of my favorite libraries: Ramda, Recompose, and Redux-Observable.
Read more >immerx-observable - npm Package Health Analysis | Snyk
We use a very basic Observable implementation under the hood and exposes a setAdapter function that we can use to transform it into...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the above example it’s:
Whereas in the current code it’s
ALL_ACTIONS
.Yeah, that’s correct. What I end up doing, at least because I’m using FlowType is:
since it lets me carve out the types within the operators just fine.
The reason it tends to be useful to have the
action$
all available is that you can use other actions to end certain streams.