Class InstrumentedStore<TState>
The instrumented store is a wrapper around a store that allows for the lifted state to be accessed and subscribed to.
Inherited Members
Namespace: Unity.AppUI.Redux.DevTools
Assembly: Unity.AppUI.Redux.dll
Syntax
public class InstrumentedStore<TState> : IInstrumentedStore<TState>, IStore<TState>, IStateProvider<TState>, INotifiable<TState>, IInstrumentedStore, IStore, IDispatchable, IDisposable
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the store state. |
Constructors
InstrumentedStore(StoreEnhancerStoreCreator<TState>, Reducer<TState>, TState, DevToolsConfiguration)
Create a new instrumented store.
Declaration
public InstrumentedStore(StoreEnhancerStoreCreator<TState> createStore, Reducer<TState> rootReducer, TState initialState, DevToolsConfiguration options)
Parameters
| Type | Name | Description |
|---|---|---|
| StoreEnhancerStoreCreator<TState> | createStore | The store creation function. |
| Reducer<TState> | rootReducer | The root reducer for the store. |
| TState | initialState | The initial state of the store. |
| DevToolsConfiguration | options | The options for the store. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if any of the arguments are null. |
Properties
dispatcher
The dispatcher that will be used to dispatch actions.
Declaration
public Dispatcher dispatcher { get; set; }
Property Value
| Type | Description |
|---|---|
| Dispatcher |
displayName
The display name of the store.
Declaration
public string displayName { get; }
Property Value
| Type | Description |
|---|---|
| string |
id
The unique identifier of the store.
Declaration
public string id { get; }
Property Value
| Type | Description |
|---|---|
| string |
reducer
The reducer function that will be used to update the state.
Declaration
public Reducer<TState> reducer { get; }
Property Value
| Type | Description |
|---|---|
| Reducer<TState> |
Methods
Dispatch(IAction)
Dispatches an action. This is the only way to trigger a state change.
Declaration
public void Dispatch(IAction action)
Parameters
| Type | Name | Description |
|---|---|---|
| IAction | action | An object describing the change that makes up the action. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the reducer for the action type does not exist. |
| ArgumentNullException | Thrown if the action is null. |
Dispose()
Declaration
public void Dispose()
GetLiftedState()
Get the current lifted state of the store.
Declaration
public LiftedState GetLiftedState()
Returns
| Type | Description |
|---|---|
| LiftedState | The current lifted state. |
GetState()
Returns a state of type TState.
Declaration
public TState GetState()
Returns
| Type | Description |
|---|---|
| TState | The state. |
Subscribe<TSelected>(Selector<LiftedState, TSelected>, Listener<TSelected>, SubscribeOptions<TSelected>)
Subscribe to the lifted state of the store.
Declaration
public IDisposableSubscription Subscribe<TSelected>(Selector<LiftedState, TSelected> selector, Listener<TSelected> listener, SubscribeOptions<TSelected> options = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Selector<LiftedState, TSelected> | selector | The selector to use to select the state. |
| Listener<TSelected> | listener | The listener to notify of state changes. |
| SubscribeOptions<TSelected> | options | The options for the subscription. |
Returns
| Type | Description |
|---|---|
| IDisposableSubscription | The subscription. |
Type Parameters
| Name | Description |
|---|---|
| TSelected | The type of the selected state. |
Subscribe<TSelected>(Selector<TState, TSelected>, Listener<TSelected>, SubscribeOptions<TSelected>)
Subscribe to a state change and listen to a specific part of the state.
Declaration
public IDisposableSubscription Subscribe<TSelected>(Selector<TState, TSelected> selector, Listener<TSelected> listener, SubscribeOptions<TSelected> options = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Selector<TState, TSelected> | selector | The selector to get the selected part of the state. |
| Listener<TSelected> | listener | The listener to be invoked on every dispatch. |
| SubscribeOptions<TSelected> | options | The options for the subscription. |
Returns
| Type | Description |
|---|---|
| IDisposableSubscription | A Subscription object that can be disposed. |
Type Parameters
| Name | Description |
|---|---|
| TSelected | The type of the selected part of the state. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if the selector or listener is null. |