Skip to content
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

Implement custom slice creators #3894

Open
wants to merge 208 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
6d3ea89
Custom slice creator implementation
EskiMojo14 Nov 18, 2023
ad94c66
rename KeysMatching and fix formatting on tsconfig
EskiMojo14 Nov 18, 2023
cad9cb9
fix docs
EskiMojo14 Nov 18, 2023
cef24b7
remove unhappy line
EskiMojo14 Nov 18, 2023
1315a65
Add custom creator test
EskiMojo14 Nov 19, 2023
204c927
use matcher to avoid slice hack
EskiMojo14 Nov 19, 2023
5074af3
use selectSlice because we can
EskiMojo14 Nov 19, 2023
be096e9
add specific error message when reducer definition type is undefined
EskiMojo14 Nov 19, 2023
aa5aae6
Merge branch 'master' into create-slice-creators
EskiMojo14 Dec 4, 2023
346f227
remove underscore
EskiMojo14 Dec 23, 2023
295eebc
update errors.json
EskiMojo14 Dec 23, 2023
0e676b6
remove unnecessary rename
EskiMojo14 Dec 27, 2023
3f502c2
add condition creator test
EskiMojo14 Dec 27, 2023
e21a7da
check promise status synchronously
EskiMojo14 Dec 27, 2023
f725ab6
use resolves chain
EskiMojo14 Dec 27, 2023
640b9c5
shuffle creator locations
EskiMojo14 Dec 27, 2023
0d7669d
add multireducer creator example
EskiMojo14 Dec 30, 2023
604799a
use symbols for reducer types, for clarity
EskiMojo14 Dec 30, 2023
888e886
Modify `BuildCreateSliceConfig` to allow passing `asyncThunk` by defa…
aryaemami59 Dec 30, 2023
5cc5509
Fix typo from `reducerWithPrepare` -> `preparedReducer`
aryaemami59 Dec 30, 2023
0d60f50
expose getInitialState to reducer creators
EskiMojo14 Dec 30, 2023
a993d91
tweak creators type to prevent autocomplete of banned keys
EskiMojo14 Dec 30, 2023
bb8cd15
change default back
EskiMojo14 Dec 30, 2023
5e299c9
pagination and history creators
EskiMojo14 Dec 30, 2023
45fa03a
add PreparedCaseReducerDefinition
EskiMojo14 Dec 30, 2023
6376f8b
separate reducer factory and prepare for more flexibility
EskiMojo14 Dec 30, 2023
821a732
rename prepare and add withoutPayload prepare
EskiMojo14 Dec 30, 2023
8e1da7b
Add checking/autocomplete for asyncThunk creator key
EskiMojo14 Dec 30, 2023
fc92596
Merge branch 'create-slice-creators' of https://github.com/reduxjs/re…
aryaemami59 Dec 30, 2023
00ac1b1
export reducer creators and reuse handlers
EskiMojo14 Dec 30, 2023
7753cec
Properly extract possible reducer definitions for a given handler
EskiMojo14 Dec 30, 2023
4d81dea
prevent overwriting handlers for reducer and reducerWithPrepare
EskiMojo14 Dec 30, 2023
6d0e07c
remove unnecessary generic
EskiMojo14 Dec 30, 2023
4cebc82
Merge branch 'create-slice-creators' of https://github.com/reduxjs/re…
aryaemami59 Dec 31, 2023
db89fb7
Fix minor type issues inside `BuildCreateSliceConfig`
aryaemami59 Dec 31, 2023
58ae809
Add some type tests for `createSlice`
aryaemami59 Dec 31, 2023
41223be
Merge pull request #4024 from aryaemami59/create-slice-creators
EskiMojo14 Dec 31, 2023
f39f4c7
only assign handler if one exists
EskiMojo14 Dec 31, 2023
d075606
Begin writing documentation
EskiMojo14 Jan 1, 2024
22f0898
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 1, 2024
fc6737f
minor tweaks
EskiMojo14 Jan 1, 2024
c90f5ba
Derive RegisteredReducerType from keys of SliceReducerCreators, remov…
EskiMojo14 Jan 1, 2024
219d1bd
rm unused util
EskiMojo14 Jan 1, 2024
7d33808
find definitions recursively regardless of depth
EskiMojo14 Jan 1, 2024
e3f8e2a
add default CreatorMap for ReducerCreators type
EskiMojo14 Jan 1, 2024
c2c948b
add ReducerNamesOfType util
EskiMojo14 Jan 1, 2024
06d3ffc
add Typescript section
EskiMojo14 Jan 1, 2024
e641fb5
use ReducerNamesOfType more
EskiMojo14 Jan 1, 2024
2b936b8
Batched creator test
EskiMojo14 Jan 1, 2024
5173d2f
define -> create
EskiMojo14 Jan 1, 2024
98e1eb5
add "single definition" example
EskiMojo14 Jan 2, 2024
aa92ced
add pagination example
EskiMojo14 Jan 2, 2024
02a4008
Add "other" example
EskiMojo14 Jan 2, 2024
1256bcb
create must be a function
EskiMojo14 Jan 2, 2024
cecda64
corrections
EskiMojo14 Jan 2, 2024
9e40fd2
Add ReducerCreatorEntry type to streamline creator registry
EskiMojo14 Jan 3, 2024
30f3b2e
simplify default
EskiMojo14 Jan 3, 2024
8787733
search attached methods for possible definitions too
EskiMojo14 Jan 3, 2024
cd9f0f9
test attached method returning definition
EskiMojo14 Jan 3, 2024
33015e5
use ReducerCreatorEntry type in docs
EskiMojo14 Jan 3, 2024
b299631
a word
EskiMojo14 Jan 3, 2024
6200338
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 3, 2024
08f41ea
Use createAppSlice name consistently
EskiMojo14 Jan 3, 2024
f35359f
Omit creator key entirely if value is never
EskiMojo14 Jan 3, 2024
7798d78
Add note about compatible state.
EskiMojo14 Jan 3, 2024
3d20781
Avoid using IfMaybeUndefined
EskiMojo14 Jan 5, 2024
139f750
guard against symbol types
EskiMojo14 Jan 5, 2024
947de20
guard against more symbols
EskiMojo14 Jan 5, 2024
e4a8289
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 5, 2024
2ef78e4
blurb it up
EskiMojo14 Jan 6, 2024
a2660af
slight tweak
EskiMojo14 Jan 6, 2024
8398520
remove extra tests now they're in the docs
EskiMojo14 Jan 8, 2024
45d765b
provide more context on buildCreateSlice
EskiMojo14 Jan 10, 2024
eacd621
move buildCreateSlice after examples
EskiMojo14 Jan 13, 2024
13c7f82
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 16, 2024
1c562a7
begin restructuring
EskiMojo14 Jan 17, 2024
0472445
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 18, 2024
e9321c5
fix entity slice enhancer test
EskiMojo14 Jan 18, 2024
d4807a6
fix createSlice test
EskiMojo14 Jan 18, 2024
209a6e6
fix 4.7 issue
EskiMojo14 Jan 18, 2024
882ee34
ensure only asyncThunkCreator is passed to asyncThunk key
EskiMojo14 Jan 18, 2024
e0cabcd
rewrite some blurbs
EskiMojo14 Jan 18, 2024
e238555
add reserved name warning
EskiMojo14 Jan 18, 2024
0178a8a
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 24, 2024
d408c32
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 26, 2024
f9e3e8e
Merge branch 'master' into create-slice-creators
EskiMojo14 Jan 29, 2024
66afcde
run prettier
EskiMojo14 Jan 29, 2024
687aa46
Added entity methods creator
EskiMojo14 Feb 3, 2024
72d105d
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 3, 2024
b5ca560
test plurals
EskiMojo14 Feb 3, 2024
a8cab74
guard against empty string and "fix" createSlice type
EskiMojo14 Feb 3, 2024
9bee39c
fix id in test
EskiMojo14 Feb 3, 2024
86dc55f
extract config to variable
EskiMojo14 Feb 3, 2024
b681ca3
fix plurals
EskiMojo14 Feb 3, 2024
a14ccd1
add entityMethodsCreator to docs
EskiMojo14 Feb 4, 2024
2f5704f
update errors.json
EskiMojo14 Feb 4, 2024
1aece5b
ensure consistency between imports and module augmentation
EskiMojo14 Feb 4, 2024
f43b01e
remove unnecessary annotation
EskiMojo14 Feb 4, 2024
01d85c9
golf
EskiMojo14 Feb 4, 2024
247c98f
match title
EskiMojo14 Feb 4, 2024
765ec1c
move collision warning
EskiMojo14 Feb 4, 2024
8d7ed3f
move ternary
EskiMojo14 Feb 4, 2024
b606bf8
add defaultplural type
EskiMojo14 Feb 4, 2024
f3612fb
import reducerCreator directly to avoid reliance on `this`
EskiMojo14 Feb 4, 2024
8714db0
unused import
EskiMojo14 Feb 4, 2024
3bbf1fa
differ internal typing for singular and plural to ensure a match
EskiMojo14 Feb 4, 2024
593e420
add comment
EskiMojo14 Feb 4, 2024
241003f
prevent any when calling entityMethodsCreator.create
EskiMojo14 Feb 4, 2024
8adeb42
improve internal type safety
EskiMojo14 Feb 4, 2024
b7eb6b9
Fix type checking in reducers field by making callback into generic
EskiMojo14 Feb 4, 2024
415b23c
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 4, 2024
63777d7
add write permissions
EskiMojo14 Feb 4, 2024
fb6ab87
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 4, 2024
619acff
adjust tests
EskiMojo14 Feb 4, 2024
d9020ac
adjust test more
EskiMojo14 Feb 4, 2024
5f8d2f4
avoid satisfies expression
EskiMojo14 Feb 4, 2024
e1f3f89
tweak createSlice logic
EskiMojo14 Feb 5, 2024
f559617
try adding a pure
EskiMojo14 Feb 5, 2024
162e482
pure more of the things
EskiMojo14 Feb 5, 2024
f5dbe61
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 5, 2024
611bd97
remove unnecessary pures
EskiMojo14 Feb 5, 2024
9456b99
fix tree shaking by comparing type instead of identity
EskiMojo14 Feb 5, 2024
db1164b
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 5, 2024
06e3203
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 5, 2024
37711f2
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 5, 2024
8360f12
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 5, 2024
9a274b0
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 10, 2024
711c8b4
remove todo
EskiMojo14 Feb 10, 2024
c8daec5
Move type test to type-d file
EskiMojo14 Feb 12, 2024
8c1c6f0
strongly type action types
EskiMojo14 Feb 12, 2024
97fa0bd
remove defaults from SliceReducerCreator
EskiMojo14 Feb 12, 2024
c0ba6ab
pass name and state to SliceReducerCreators when getting final action…
EskiMojo14 Feb 12, 2024
01feaae
use CreatorCaseReducers type in more places
EskiMojo14 Feb 12, 2024
8af2b00
cast harder
EskiMojo14 Feb 12, 2024
c8af945
add notes about type parameters
EskiMojo14 Feb 12, 2024
869db56
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 12, 2024
7118f1a
remove unused barrel file
EskiMojo14 Feb 12, 2024
ca7b1da
fix imports in tests
EskiMojo14 Feb 12, 2024
96b3084
add named selectors
EskiMojo14 Feb 12, 2024
2653a61
call with whole action
EskiMojo14 Feb 12, 2024
29d70bb
ensure selectors are computed
EskiMojo14 Feb 13, 2024
3d2ecf6
remove unused PURE
EskiMojo14 Feb 15, 2024
de1f721
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 17, 2024
46e792b
byte shaving
EskiMojo14 Feb 18, 2024
930e868
expose sliceName to reducer handler
EskiMojo14 Feb 18, 2024
ece8442
split asyncThunkCreator into its own file
EskiMojo14 Feb 18, 2024
4af6bd4
fix typo
EskiMojo14 Feb 18, 2024
a53a0c6
fix type imports
EskiMojo14 Feb 18, 2024
09cc0c7
split type test
EskiMojo14 Feb 18, 2024
7252c16
move module augmentation back to createSlice
EskiMojo14 Feb 18, 2024
5f5fe79
Rework mapped type to keep homogenous mapping
EskiMojo14 Feb 18, 2024
31c4794
there are no entity methods creators in ba sing se
EskiMojo14 Feb 18, 2024
82c9262
reset more entity files
EskiMojo14 Feb 18, 2024
4db2dcc
again
EskiMojo14 Feb 18, 2024
ebfd549
fix test
EskiMojo14 Feb 19, 2024
bd73745
remove ReducerNamesOfType
EskiMojo14 Feb 19, 2024
82da65d
bump version reference
EskiMojo14 Feb 19, 2024
cff430e
Merge branch 'master' into create-slice-creators
EskiMojo14 Feb 21, 2024
37bd76e
add usage page
EskiMojo14 Feb 22, 2024
633028d
move creator callback section back and cut and paste slice creators s…
EskiMojo14 Feb 22, 2024
2ce8b30
take titles down a step
EskiMojo14 Feb 22, 2024
7e60c5a
a word
EskiMojo14 Feb 22, 2024
e310604
fix links
EskiMojo14 Feb 23, 2024
ad6a8e5
Merge branch 'master' into create-slice-creators
EskiMojo14 Mar 11, 2024
7148e8c
omit any from extracted definitions
EskiMojo14 Mar 12, 2024
b05b9a7
cast more anys
EskiMojo14 Mar 12, 2024
94937b1
rename context types
EskiMojo14 Apr 5, 2024
5403d80
remove first argument for exposeAction and exposeCaseReducer, and alw…
EskiMojo14 Apr 5, 2024
90555ee
add tests for context errors
EskiMojo14 Apr 5, 2024
2e25c1f
add note about only calling methods once
EskiMojo14 Apr 5, 2024
e3b8d90
expose selectSlice, name and reducerPath in context
EskiMojo14 Apr 5, 2024
2cb7e47
expose Name and ReducerPath in types, and add test for selectSlice
EskiMojo14 Apr 5, 2024
bfc9bae
move reducerPath to reducerDetails
EskiMojo14 Apr 5, 2024
51aecbc
simplify selectSlice types
EskiMojo14 Apr 5, 2024
27950e1
update docs definitions to match
EskiMojo14 Apr 5, 2024
8c1a64f
update errors.json
EskiMojo14 Apr 5, 2024
3f82d47
update docs with new options
EskiMojo14 Apr 5, 2024
bde0288
avoid satisfies for type test
EskiMojo14 Apr 5, 2024
0d55413
Merge branch 'master' into create-slice-creators
EskiMojo14 Apr 5, 2024
1f1ac68
add no-transpile to snippet
EskiMojo14 Apr 5, 2024
7aa3933
test symbol errors
EskiMojo14 Apr 6, 2024
c2523fc
golf
EskiMojo14 Apr 6, 2024
a9e3fa4
make sure each creator symbol has a description
EskiMojo14 Apr 6, 2024
02bbfba
simplify GetCaseReducers
EskiMojo14 Apr 6, 2024
0133506
use utility more
EskiMojo14 Apr 6, 2024
f86a6d5
unsimplify GetCaseReducers because it broke everything
EskiMojo14 Apr 8, 2024
52d8d12
golf
EskiMojo14 Apr 8, 2024
5e256a6
remove unnecessary cast
EskiMojo14 Apr 8, 2024
a84abbd
expand upon creator docs further
EskiMojo14 Apr 8, 2024
5fe391e
Merge branch 'master' into create-slice-creators
EskiMojo14 May 22, 2024
f8ad517
move async thunk creator module augmentation
EskiMojo14 May 22, 2024
cdf4498
try something different
EskiMojo14 May 22, 2024
2d08f5d
tweak example
EskiMojo14 May 29, 2024
6226c1d
add note about exposing multiple values per reducer def
EskiMojo14 May 29, 2024
ce04544
add note about addMatcher order
EskiMojo14 May 29, 2024
32cdde8
limit recursion depth of definition extraction
EskiMojo14 Jun 3, 2024
0f01293
rm unused type
EskiMojo14 Jun 3, 2024
45c8b9e
guard against strange behaviour of OverloadedReturnType in pre 5.3 ve…
EskiMojo14 Jun 4, 2024
99c0c7f
condense OverloadedReturnType since first conditional is always hit
EskiMojo14 Jun 4, 2024
62e96d5
remove note re: addMatcher order as it doesn't apply
EskiMojo14 Jun 10, 2024
a12524a
remove requirement for create to be a function
EskiMojo14 Jun 14, 2024
e99e084
test non-function creator
EskiMojo14 Jun 14, 2024
3ec07e9
Merge branch 'master' into create-slice-creators
EskiMojo14 Sep 1, 2024
b6d1d5d
fix type portability examples
EskiMojo14 Sep 1, 2024
e9744e0
Merge branch 'master' into create-slice-creators
EskiMojo14 Sep 1, 2024
b10f345
switch back to an interface
EskiMojo14 Sep 1, 2024
ef2d024
avoid relative declaration
EskiMojo14 Sep 3, 2024
2d7def1
Merge branch 'master' into create-slice-creators
EskiMojo14 Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/createEntityAdapter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ In other words, they accept a state that looks like `{ids: [], entities: {}}`, a

These CRUD methods may be used in multiple ways:

- They may be passed as case reducers directly to `createReducer` and `createSlice`.
- They may be passed as case reducers directly to `createReducer` and `createSlice`. (also see the [`create.entityMethods`](./createSlice#createentitymethods-entitymethodscreator) slice creator which can assist with this)
- They may be used as "mutating" helper methods when called manually, such as a separate hand-written call to `addOne()` inside of an existing case reducer, if the `state` argument is actually an Immer `Draft` value.
- They may be used as immutable update methods when called manually, if the `state` argument is actually a plain JS object or array.

Expand Down
Loading
Loading