-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create slice changes #197
Create slice changes #197
Conversation
Deploy preview for redux-starter-kit-docs ready! Built with commit c58aa2c https://deploy-preview-197--redux-starter-kit-docs.netlify.com |
Great, thanks! Ironically, I'm actually having second thoughts about the "return the reducer" thing: https://twitter.com/acemarke/status/1175881949514219521 It's an interesting idea, and yet at the same time I'm not sure it buys much actual improvement. Thoughts? |
It's definitely nicer to use (took my a while to figure out that I could not use the slice directly in combineReducers), but the console.log in chrome is really bad :/ What about turning the idea around? Export a modified combineReducers from RSK that takes either functions or slices? |
No, one of the main points of RSK is that it's "just Redux". I don't want to have a special version of Y'know, I think I've talked myself out of returning the reducer directly. Returning the object gives us a bit more flexibility in case we ever do add something else to Sorry for the whiplash :) |
@phryneas : just re-read your comment in the 1.0 thread. Yeah, sure, let's go ahead and include the individual reducers in the slice object (which is also another argument for keeping it as an object). Main question is what to call it? Maybe Semi-recapping: const sliceObj = createSlice({
name: "todos",
initialState,
reducers: {
addTodo() {},
toggleTodo() {}
}
});
console.log(sliceObj);
/*
{
actions: {addTodo, toggleTodo},
reducer : fn(),
caseReducers: {addTodo, toggleTodo}
}
*/ |
@markerikson okay. I'll revert the "reducer function" commit so that this can get merged and open a separate PR for the |
c5dabec
to
c58aa2c
Compare
DOH! I should actually read the code, shouldn't I :) |
Awright, looks good to me! |
* Create slice changes (#197) * Include case reducers in createSlice result (#209) * Fix missing name field in type test * Include provided case reducers in createSlice output - Added `caseReducers` field to the createSlice return object - Added test and type test for returned case reducer - Removed "Enhanced" terminology from types, and replaced with "CaseReducerWithPrepare" and "CaseReducerDefinition" - Restructured logic to only loop over reducer names once, and check case reducer definition type once per entry * Add type tests for correct case reducer export inference * Rewrite caseReducers types for correct inference of state + action * Add type test for reducers with prepare callback * Fix type inference for actions from reducers w/ prepare callbacks * Clean up type names and usages * Use a generic State type in ActionForReducer * Re-switch Slice generics order * Use `void` instead of `any` for undefined payloads (#174) * Change default createAction payload type to void to make it required * Fix createAction type tests per review * Update tutorials for v0.8 (#213) * Update basic tutorial with createSlice changes * Update intermediate tutorial with createSlice changes * Update advanced tutorial with createSlice changes * Change existing commit links to point to reduxjs org repos
These are the changes you requested over in #82