docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Slice<TState, TStoreState>

    A Slice is a collection of reducers and actions for a specific domain. It is a convenient way to bundle them together for use in a Redux store.

    Inheritance
    object
    Slice<TState, TStoreState>
    Implements
    ISlice<TStoreState>
    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
    [Preserve]
    public class Slice<TState, TStoreState> : ISlice<TStoreState> where TStoreState : IPartionableState<TStoreState>
    Type Parameters
    Name Description
    TState

    The type of the state associated with this slice.

    TStoreState

    The type of the store state.

    Constructors

    Slice(string, TState, Action<SliceReducerSwitchBuilder<TState>>, Action<ReducerSwitchBuilder<TState>>)

    Create a new state slice. A state slice is a part of the state tree. You can provide reducers that will "own" the state slice at the same time.

    Declaration
    [Preserve]
    public Slice(string name, TState initialState, Action<SliceReducerSwitchBuilder<TState>> reducers, Action<ReducerSwitchBuilder<TState>> extraReducers = null)
    Parameters
    Type Name Description
    string name

    The name of the state slice.

    TState initialState

    The initial state of the state slice.

    Action<SliceReducerSwitchBuilder<TState>> reducers

    The reducers that will "own" the state slice.

    Action<ReducerSwitchBuilder<TState>> extraReducers

    The reducers that will be called if the action type does not match any of the main reducers.

    Remarks

    You can also provide extra reducers that will be called if the action type does not match any of the main reducers.

    Properties

    actionCreators

    The action creators for this slice.

    Declaration
    public Dictionary<string, IActionCreator> actionCreators { get; }
    Property Value
    Type Description
    Dictionary<string, IActionCreator>

    initialState

    The initial state for this slice.

    Declaration
    public TState initialState { get; }
    Property Value
    Type Description
    TState

    name

    The name of the slice.

    Declaration
    public string name { get; }
    Property Value
    Type Description
    string

    reducer

    The reducer for this slice.

    Declaration
    public Reducer<TState> reducer { get; }
    Property Value
    Type Description
    Reducer<TState>

    Methods

    InitializeState(TStoreState)

    Set the initial state of the slice. This is used internally by Unity.AppUI.Redux.Store.CreateStore``2(System.Collections.Generic.IReadOnlyCollection{Unity.AppUI.Redux.ISlice{``1}},Unity.AppUI.Redux.StoreEnhancer{Unity.AppUI.Redux.Store{``1}.CreationContext,``1}).

    Declaration
    public TStoreState InitializeState(TStoreState state)
    Parameters
    Type Name Description
    TStoreState state

    The initial state of the store.

    Returns
    Type Description
    TStoreState

    The new state of the store.

    Reduce(TStoreState, IAction)

    The wrapped reducer of the slice for being used in the store.

    Declaration
    public TStoreState Reduce(TStoreState state, IAction action)
    Parameters
    Type Name Description
    TStoreState state

    The current state of the store.

    IAction action

    The action to apply to the state.

    Returns
    Type Description
    TStoreState

    The new state of the store.

    Implements

    ISlice<TStoreState>
    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)