docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SwitchBuilder<TBuilder, TState>

    Base implementation of a switch statement builder to generate a reducer.

    Inheritance
    object
    SwitchBuilder<TBuilder, TState>
    ReducerSwitchBuilder<TState>
    SliceReducerSwitchBuilder<TState>
    Implements
    ISwitchBuilder<TBuilder, TState>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.Redux
    Assembly: Unity.AppUI.Redux.dll
    Syntax
    public class SwitchBuilder<TBuilder, TState> : ISwitchBuilder<TBuilder, TState> where TBuilder : SwitchBuilder<TBuilder, TState>
    Type Parameters
    Name Description
    TBuilder

    The type of the builder.

    TState

    The type of the state.

    Constructors

    SwitchBuilder()

    Default constructor for the switch builder.

    Declaration
    public SwitchBuilder()

    Fields

    m_ActionTypes

    The action types that are already handled.

    Declaration
    protected readonly HashSet<string> m_ActionTypes
    Field Value
    Type Description
    HashSet<string>

    Methods

    AddCase(IActionCreator, Reducer<TState>)

    Adds a case to the reducer switch statement.

    Declaration
    public virtual TBuilder AddCase(IActionCreator actionCreator, Reducer<TState> reducer)
    Parameters
    Type Name Description
    IActionCreator actionCreator

    The action creator for the action type you want to handle.

    Reducer<TState> reducer

    The reducer function for the action type you want to handle.

    Returns
    Type Description
    TBuilder

    The builder instance to chain calls.

    AddCase<TPayload>(IActionCreator<TPayload>, Reducer<TPayload, TState>)

    Adds a case to the reducer switch statement.

    Declaration
    public virtual TBuilder AddCase<TPayload>(IActionCreator<TPayload> actionCreator, Reducer<TPayload, TState> reducer)
    Parameters
    Type Name Description
    IActionCreator<TPayload> actionCreator

    The action creator for the action type you want to handle.

    Reducer<TPayload, TState> reducer

    The reducer function for the action type you want to handle.

    Returns
    Type Description
    TBuilder

    The builder instance to chain calls.

    Type Parameters
    Name Description
    TPayload

    The type of the action payload.

    GetActionCreators()

    Create a dictionary of action creator per action type.

    Declaration
    public virtual Dictionary<string, IActionCreator> GetActionCreators()
    Returns
    Type Description
    Dictionary<string, IActionCreator>

    The dictionary of action creators.

    GetReducer()

    Get the reducer output function.

    Declaration
    public Reducer<TState> GetReducer()
    Returns
    Type Description
    Reducer<TState>

    The reducer function.

    ValidateCase(IActionCreator, object)

    Validates the case to ensure it is not a duplicate.

    Declaration
    protected virtual void ValidateCase(IActionCreator actionCreator, object reducer)
    Parameters
    Type Name Description
    IActionCreator actionCreator

    The action creator.

    object reducer

    The reducer.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the action creator or reducer is null.

    InvalidOperationException

    Thrown if the action type is already handled.

    Implements

    ISwitchBuilder<TBuilder, TState>
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)