Class Store
A store that holds the complete state tree of your app using slices.
Inherited Members
Namespace: Unity.AppUI.Redux
Assembly: Unity.AppUI.Redux.dll
Syntax
[Preserve]
public class Store : Store<PartitionedState>, INotifiable<PartitionedState>, IStateProvider<PartitionedState>, IDispatchable
Constructors
Store(Reducer<PartitionedState>, PartitionedState, Dispatcher)
Creates a Redux store that holds the complete state tree of your app.
Declaration
[Preserve]
public Store(Reducer<PartitionedState> rootReducer, PartitionedState initialState, Dispatcher dispatcher)
Parameters
| Type | Name | Description |
|---|---|---|
| Reducer<PartitionedState> | rootReducer | The root reducer of the store. |
| PartitionedState | initialState | The initial state of the store. |
| Dispatcher | dispatcher | The dispatcher of the store. |
Remarks
You should not use directly this constructor to create a store.
Instead, use StoreFactory.CreateStore{TStoreState} to create a store with optional enhancers.
This constructor should be called only by enhancers to return an enhanced store.
Methods
ApplyMiddleware<TStore, TStoreState>(params Middleware<TStore, TStoreState>[])
Apply middlewares to the store.
Declaration
public static StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> ApplyMiddleware<TStore, TStoreState>(params Middleware<TStore, TStoreState>[] middlewares) where TStore : Store<TStoreState>
Parameters
| Type | Name | Description |
|---|---|---|
| Middleware<TStore, TStoreState>[] | middlewares | The middlewares to apply. |
Returns
| Type | Description |
|---|---|
| StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> | A new store enhancer. |
Type Parameters
| Name | Description |
|---|---|
| TStore | The type of the store. |
| TStoreState | The type of the store state. |
CombineReducers<TState>(IEnumerable<Reducer<TState>>)
Create a reducer that combines multiple reducers into one.
Declaration
public static Reducer<TState> CombineReducers<TState>(IEnumerable<Reducer<TState>> reducers)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Reducer<TState>> | reducers | The reducers to combine. |
Returns
| Type | Description |
|---|---|
| Reducer<TState> | A reducer that combines the given reducers. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the state. |
CombineReducers<TStoreState>(IReadOnlyCollection<ISlice<TStoreState>>)
Create a reducer that combines multiple slices into one.
Declaration
public static Reducer<TStoreState> CombineReducers<TStoreState>(IReadOnlyCollection<ISlice<TStoreState>> slices)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<ISlice<TStoreState>> | slices | The slices to combine. |
Returns
| Type | Description |
|---|---|
| Reducer<TStoreState> | A reducer that combines the given slices. |
Type Parameters
| Name | Description |
|---|---|
| TStoreState | The type of the store state. |
CombineReducers<TState>(params Reducer<TState>[])
Create a reducer that combines multiple reducers into one.
Declaration
public static Reducer<TState> CombineReducers<TState>(params Reducer<TState>[] reducers)
Parameters
| Type | Name | Description |
|---|---|---|
| Reducer<TState>[] | reducers | The reducers to combine. |
Returns
| Type | Description |
|---|---|
| Reducer<TState> | A reducer that combines the given reducers. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the state. |
ComposeEnhancers<TStoreState>(params StoreEnhancer<CreationContext, TStoreState>[])
Compose enhancers into a single enhancer.
Declaration
public static StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> ComposeEnhancers<TStoreState>(params StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState>[] enhancers)
Parameters
| Type | Name | Description |
|---|---|---|
| StoreEnhancer<CreationContext, TStoreState>[] | enhancers | The enhancers to compose. |
Returns
| Type | Description |
|---|---|
| StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> | A new store enhancer. |
Type Parameters
| Name | Description |
|---|---|
| TStoreState | The type of the store state. |
CreateAction(string)
Create a new Action. See Action for more information.
Declaration
public static ActionCreator CreateAction(string type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the action. |
Returns
| Type | Description |
|---|---|
| ActionCreator | A new Action. |
CreateAction(string, Type)
Create a new Action. See Action<TPayload> for more information.
Declaration
public static IActionCreator CreateAction(string type, Type actionType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the action. |
| Type | actionType | The type of the action to instantiate. |
Returns
| Type | Description |
|---|---|
| IActionCreator | A new Action. |
CreateAction<TPayload>(string)
Create a new Action. See Action<TPayload> for more information.
Declaration
public static ActionCreator<TPayload> CreateAction<TPayload>(string type)
Parameters
| Type | Name | Description |
|---|---|---|
| string | type | The type of the action. |
Returns
| Type | Description |
|---|---|
| ActionCreator<TPayload> | A new Action. |
Type Parameters
| Name | Description |
|---|---|
| TPayload | The type of the payload. |
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 static Slice<TState, PartitionedState> 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, PartitionedState> | A slice object that can be used to access the state slice. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the slice 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 |
|---|---|
| ArgumentNullException | Thrown if the name is null or empty. |
CreateStore(IReadOnlyCollection<ISlice<PartitionedState>>, StoreEnhancer<CreationContext, PartitionedState>)
Creates a Redux store composed of multiple slices.
Declaration
public static Store CreateStore(IReadOnlyCollection<ISlice<PartitionedState>> slices, StoreEnhancer<Store<PartitionedState>.CreationContext, PartitionedState> enhancer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<ISlice<PartitionedState>> | slices | The slices that compose the store. |
| StoreEnhancer<Store<PartitionedState>.CreationContext, PartitionedState> | enhancer | The enhancer for the store. |
Returns
| Type | Description |
|---|---|
| Store | The new store. |
Remarks
This is a specialization of CreateStore<TStore, TStoreState>(IReadOnlyCollection<ISlice<TStoreState>>, StoreEnhancer<CreationContext, TStoreState>) for a Store that uses PartitionedState.
CreateStore(Reducer<PartitionedState>, PartitionedState, StoreEnhancer<CreationContext, PartitionedState>)
Creates a Redux store that holds the complete state tree of your app.
Declaration
public static Store CreateStore(Reducer<PartitionedState> rootReducer, PartitionedState initialState = null, StoreEnhancer<Store<PartitionedState>.CreationContext, PartitionedState> enhancer = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Reducer<PartitionedState> | rootReducer | The root reducer of the store. |
| PartitionedState | initialState | The initial state of the store. |
| StoreEnhancer<Store<PartitionedState>.CreationContext, PartitionedState> | enhancer | The enhancer for the store. |
Returns
| Type | Description |
|---|---|
| Store | A new store. |
Remarks
This is a specialization of CreateStore<TStore, TStoreState>(Reducer<TStoreState>, TStoreState, StoreEnhancer<CreationContext, TStoreState>) for a Store that uses PartitionedState.
CreateStore<TStore, TStoreState>(IReadOnlyCollection<ISlice<TStoreState>>, StoreEnhancer<CreationContext, TStoreState>)
Creates a Redux store composed of multiple slices.
Declaration
public static TStore CreateStore<TStore, TStoreState>(IReadOnlyCollection<ISlice<TStoreState>> slices, StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> enhancer = null) where TStore : Store<TStoreState> where TStoreState : IPartionableState<TStoreState>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyCollection<ISlice<TStoreState>> | slices | The slices that compose the store. |
| StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> | enhancer | The enhancer for the store. |
Returns
| Type | Description |
|---|---|
| TStore | The new store. |
Type Parameters
| Name | Description |
|---|---|
| TStore | The type of the store. |
| TStoreState | The type of the store state. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the slices are null. |
CreateStore<TStore, TStoreState>(Reducer<TStoreState>, TStoreState, StoreEnhancer<CreationContext, TStoreState>)
Creates a Redux store that holds the complete state tree of your app.
Declaration
public static TStore CreateStore<TStore, TStoreState>(Reducer<TStoreState> rootReducer, TStoreState initialState = default, StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> enhancer = null) where TStore : Store<TStoreState> where TStoreState : new()
Parameters
| Type | Name | Description |
|---|---|---|
| Reducer<TStoreState> | rootReducer | The root reducer of the store. |
| TStoreState | initialState | The initial state of the store. |
| StoreEnhancer<Store<TStoreState>.CreationContext, TStoreState> | enhancer | The enhancer for the store. |
Returns
| Type | Description |
|---|---|
| TStore | A new store. |
Type Parameters
| Name | Description |
|---|---|
| TStore | The type of the store. |
| TStoreState | The type of the store state. |