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.
Implements
Inherited Members
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<Slice |
reducers | The reducers that will "own" the state slice. |
Action<Reducer |
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, IAction |
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.
Declaration
public TStoreState InitializeState(TStoreState state)
Parameters
Type | Name | Description |
---|---|---|
TStore |
state | The initial state of the store. |
Returns
Type | Description |
---|---|
TStore |
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 |
---|---|---|
TStore |
state | The current state of the store. |
IAction | action | The action to apply to the state. |
Returns
Type | Description |
---|---|
TStore |
The new state of the store. |