Class ReducerSwitchBuilder<TState>
The Reducer Switch Builder is used to build a reducer switch statement via method chaining. You must have created Action Creators for each action type you want to handle prior to using this.
Implements
Inherited Members
Namespace: Unity.AppUI.Redux
Assembly: Unity.AppUI.Redux.dll
Syntax
public class ReducerSwitchBuilder<TState> : SwitchBuilder<ReducerSwitchBuilder<TState>, TState>, ISwitchBuilder<ReducerSwitchBuilder<TState>, TState>, ISwitchMatchBuilder<ReducerSwitchBuilder<TState>, TState>
Type Parameters
Name | Description |
---|---|
TState | The type of the state slice. |
Methods
AddCase(ActionMatcher, Reducer<TState>)
Adds a matcher case to the reducer switch statement. A matcher case is a case that will be executed if the action type matches the predicate.
Declaration
public ReducerSwitchBuilder<TState> AddCase(ActionMatcher actionMatcher, Reducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionMatcher | actionMatcher | The predicate that will be used to match the action type. |
Reducer<TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
AddCase<TPayload>(ActionMatcher, Reducer<TPayload, TState>)
Adds a matcher case to the reducer switch statement. A matcher case is a case that will be executed if the action type matches the predicate.
Declaration
public ReducerSwitchBuilder<TState> AddCase<TPayload>(ActionMatcher actionMatcher, Reducer<TPayload, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionMatcher | actionMatcher | The predicate that will be used to match the action type. |
Reducer<TPayload, TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
Type Parameters
Name | Description |
---|---|
TPayload | The type of the action payload. |
AddDefault(Reducer<TState>)
Adds a default case to the reducer switch statement. A default case is a case that will be executed if no other cases match.
Declaration
public ReducerSwitchBuilder<TState> AddDefault(Reducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
Reducer<TState> | reducer | The reducer function for the default case. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |