Class SliceReducerSwitchBuilder<TState>
The Slice Reducer Switch Builder is used to build a reducer switch statement via method chaining. This builder does not require you to create Action Creators. It will automatically create them for you.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.Redux
Assembly: Unity.AppUI.Redux.dll
Syntax
public class SliceReducerSwitchBuilder<TState> : SwitchBuilder<SliceReducerSwitchBuilder<TState>, TState>, ISwitchBuilder<SliceReducerSwitchBuilder<TState>, TState>
Type Parameters
Name | Description |
---|---|
TState | The type of the state slice. |
Constructors
SliceReducerSwitchBuilder(string)
Creates a new Slice Reducer Switch Builder.
Declaration
public SliceReducerSwitchBuilder(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the slice. |
Properties
name
The name of the slice.
Declaration
public string name { get; }
Property Value
Type | Description |
---|---|
string |
Methods
Add(string, CaseReducer<TState>)
Adds a case to the reducer switch statement.
Declaration
[Obsolete]
public SliceReducerSwitchBuilder<TState> Add(string actionType, CaseReducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
string | actionType | The action type you want to handle. |
CaseReducer<TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
SliceReducerSwitchBuilder<TState> | The Slice Reducer Switch Builder. |
Add(CaseReducer<TState>)
Adds a case to the reducer switch statement.
Declaration
[Obsolete]
public SliceReducerSwitchBuilder<TState> Add(CaseReducer<TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
CaseReducer<TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
SliceReducerSwitchBuilder<TState> | The Slice Reducer Switch Builder. |
Add<T>(string, CaseReducer<T, TState>)
Adds a case to the reducer switch statement.
Declaration
[Obsolete]
public SliceReducerSwitchBuilder<TState> Add<T>(string actionType, CaseReducer<T, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
string | actionType | 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 |
---|---|
SliceReducerSwitchBuilder<TState> | The Slice Reducer Switch Builder. |
Type Parameters
Name | Description |
---|---|
T | The type of the payload. |
Add<T>(CaseReducer<T, TState>)
Adds a case to the reducer switch statement.
Declaration
[Obsolete]
public SliceReducerSwitchBuilder<TState> Add<T>(CaseReducer<T, TState> reducer)
Parameters
Type | Name | Description |
---|---|---|
CaseReducer<T, TState> | reducer | The reducer function for the action type you want to handle. |
Returns
Type | Description |
---|---|
SliceReducerSwitchBuilder<TState> | The Slice Reducer Switch Builder. |
Type Parameters
Name | Description |
---|---|
T | The type of the payload. |
BuildReducers(IEnumerable<ActionCreator>)
Build the reducer switch statement.
Declaration
[Obsolete("BuildReducers is deprecated. Use BuildReducers(IEnumerable<ActionCreator>) instead.")]
public Action<ReducerSwitchBuilder<TState>> BuildReducers(IEnumerable<ActionCreator> actionCreatorCollection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ActionCreator> | actionCreatorCollection | The collection of Action Creators. |
Returns
Type | Description |
---|---|
Action<ReducerSwitchBuilder<TState>> | The reducer switch statement. |
ValidateCase(IActionCreator, object)
Validates the case to ensure it is not a duplicate.
Declaration
protected override void ValidateCase(IActionCreator actionCreator, object reducer)
Parameters
Type | Name | Description |
---|---|---|
IActionCreator | actionCreator | The action creator. |
object | reducer | The reducer. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the action creator or reducer is null. |
InvalidOperationException | Thrown if the action type is already handled. |
InvalidOperationException | Thrown if the action type does not start with the slice name. |