Method CreateSlice
CreateSlice<TState>(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
public Slice<TState> CreateSlice<TState>(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. |
Returns
Type | Description |
---|---|
Slice<TState> | A slice object that can be used to access the state slice. |
Type Parameters
Name | Description |
---|---|
TState | The type of the state. |
Remarks
You can also provide extra reducers that will be called if the action type does not match any of the main reducers.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the state slice already exists. |