-
-
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
Allow providing custom slice creators when calling createSlice #4348
Open
EskiMojo14
wants to merge
22
commits into
entity-methods-creator
Choose a base branch
from
per-slice-creator
base: entity-methods-creator
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+164
−20
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a4ba0ce
Experiment with allowing providing custom slice creators when calling…
EskiMojo14 e9e7818
rm unused import
EskiMojo14 108f6b3
add type test for overlapping names
EskiMojo14 42363fa
add overlap test
EskiMojo14 15f01b9
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 d976ea5
move async thunk creator module augmentation
EskiMojo14 27e0ef8
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 71e3d04
create util to cut down on repetitive code
EskiMojo14 bae8ce9
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 fea70e4
update docs
EskiMojo14 0ccf470
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 ed623ac
fix creator issue
EskiMojo14 4decf83
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 083d6e4
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 5654eb2
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 4de4ab7
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 e4dbc9a
Retry CSB build
EskiMojo14 5d1969d
fix Id usage
EskiMojo14 d105924
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 25bc1a7
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 0d28d41
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 2f5500b
Merge branch 'entity-methods-creator' into per-slice-creator
EskiMojo14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain the differences between this and the traditional builder pattern? Also, would you mind clarifying the purpose of the custom loadCreator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what traditional builder pattern are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reference was to the action builder pattern in Redux Toolkit, where we use methods like addCase and addMatcher in createSlice to dynamically build actions and reducers. With this PR allowing custom slice creators, I wonder if there are potential issues when multiple creators are provided for the same slice. Could this lead to naming conflicts or unexpected behavior if two creators define overlapping functionality for the same action or state? I might be missing something though haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extraReducers
has a different builder pattern, because we don't need a return value from it. forreducers
we need the returned object to infer slice actions and case reducers from, similar to how you're required to returnbuild.query
when building an RTKQ API.There's handling for overlaps, this is the third PR in a set of three. See #3837 for the base logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh gotcha, thanks Ben!