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.
Inherited Members
Namespace: Unity.AppUI.Redux
Assembly: Unity.AppUI.Redux.dll
Syntax
public class ReducerSwitchBuilder<TState>
Type Parameters
Name | Description |
---|---|
TState | The type of the state slice. |
Methods
AddCase(ActionCreator, CaseReducer<TState>)
Adds a case to the reducer switch statement.
Declaration
public ReducerSwitchBuilder<TState> AddCase(ActionCreator action, CaseReducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionCreator | action | The action creator for the action type you want to handle. |
CaseReducer<TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
AddCase<T>(ActionCreator<T>, CaseReducer<T, TState>)
Adds a case to the reducer switch statement.
Declaration
public ReducerSwitchBuilder<TState> AddCase<T>(ActionCreator<T> action, CaseReducer<T, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionCreator<T> | action | The action creator for the action type you want to handle. |
CaseReducer<T, 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 |
---|---|
T | The type of the action payload. |
AddDefaultCase(CaseReducer<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> AddDefaultCase(CaseReducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
CaseReducer<TState> | reducer | The reducer function for the default case. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
AddDefaultCase<T>(CaseReducer<T, 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> AddDefaultCase<T>(CaseReducer<T, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
CaseReducer<T, TState> | reducer | The reducer function for the default case. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
Type Parameters
Name | Description |
---|---|
T | The type of the action payload. |
AddMatcher(ActionMatcher, CaseReducer<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> AddMatcher(ActionMatcher actionMatcher, CaseReducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionMatcher | actionMatcher | The predicate that will be used to match the action type. |
CaseReducer<TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
ReducerSwitchBuilder<TState> | The Reducer Switch Builder. |
AddMatcher<T>(ActionMatcher, CaseReducer<T, 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> AddMatcher<T>(ActionMatcher actionMatcher, CaseReducer<T, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
ActionMatcher | actionMatcher | The predicate that will be used to match the action type. |
CaseReducer<T, 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 |
---|---|
T | The type of the action payload. |
BuildReducer(TState)
Builds the reducer switch statement.
Declaration
public Reducer BuildReducer(TState initialState)
Parameters
Type | Name | Description |
---|---|---|
TState | initialState | The initial state of the reducer. |
Returns
Type | Description |
---|---|
Reducer | The reducer switch statement. |