You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same as [`addMatcher`](../api/createReducer#builderaddmatcher) for `createReducer` and `extraReducers`. Adds a case reducer which will be called when a given matcher returns true.
// available as slice.actions[reducerName].hidden and slice.actions[reducerName].shown
485
+
```
473
486
474
487
:::
475
488
@@ -481,6 +494,49 @@ Attaches a value to `slice.caseReducers[reducerName]`.
481
494
context.exposeCaseReducer(reducer)
482
495
```
483
496
497
+
Returns the context object to allow chaining.
498
+
499
+
:::caution
500
+
501
+
Just like `exposeAction`, `exposeCaseReducer` should only be called once (at maximum) within a `handle` callback.
502
+
503
+
If you want to expose multiple values for a given case reducer definition, you can pass an object to `exposeCaseReducer`.
504
+
505
+
```ts no-transpile
506
+
context.exposeCaseReducer({
507
+
hidden: config.hidden||noop,
508
+
shown: config.shown||noop,
509
+
})
510
+
// available as slice.caseReducers[reducerName].hidden and slice.caseReducers[reducerName].shown
511
+
```
512
+
513
+
You can see an example of this with the `asyncThunk` creator in the [RTK creators](#rtk-creators) section, which exposes case reducers for each of the lifecycle actions.
0 commit comments