Closed venkatd closed 6 years ago
Thanks for the compliment!
So If I understand you correctly, you would like me to return initialState
from the robodux
function?
Yeah exactly. I suppose you'd have to add an entry here? https://github.com/neurosnap/robodux/blob/master/src/slice.ts#L53
Also, I'm guessing you would somehow need to combine the initial states to support this with combinedReducers
Yep! I'm totally okay with this change. You are more than welcome to submit a PR and I'll merge and deploy to npm
@neurosnap on second thought I wonder if it's better to have this belong to the reducer instead of the slice.
Meaning:
createStore<StoreState, any, any, any>(RootSlice.reducer, RootSlice.reducer.initialState, enhancer);
I conflated slices and reducers. What do you think?
Another update haha. I don't think this is the way to go after having read this: https://redux.js.org/recipes/structuringreducers/initializingstate#recap
Seems like I should be able to write createStore(RootSlice.reducer, {}, enhancer)
but not sure if this is a limitation of the redux typings or robodux. Will write back once I've dug into this more.
Does createStore(RootSlice.reducer, undefined, enhancer)
work?
Interestingly it compiles and runs but the vscode editor complains with the following:
Argument of type 'undefined' is not assignable to parameter of type 'DeepPartial<any>'.
I don't think there is anything to be done with robodux since the issue (if any) is with the createStore
type signature. Potentially I could issue a PR for the readme explaining different approaches to create the store.
Great work on this lib! Just swapped over and it removed a lot of boilerplate.
Currently I have to write:
const store = createStore<StoreState, any, any, any>(RootReducer.reducer, {commands: [], events: []}, enhancer)
I would prefer to write:
const store = createStore<StoreState, any, any, any>(RootReducer.reducer, RootReducer.initialState, enhancer);
I have already defined the initial state so think I should be able to access the
initialState
directly. Thoughts?