Class StoreExtensions
Extensions for the Store.
Inherited Members
Namespace: Unity.AppUI.Redux
Assembly: Unity.AppUI.Redux.dll
Syntax
public static class StoreExtensions
Methods
AsyncThunkCoroutine<TPayload, TThunkArg>(Store, AsyncThunkAction<TPayload, TThunkArg>, CancellationToken)
Coroutine to dispatch an async thunk action.
Declaration
public static IEnumerator AsyncThunkCoroutine<TPayload, TThunkArg>(this Store store, AsyncThunkAction<TPayload, TThunkArg> asyncThunkAction, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Store | store | The store to dispatch the action to. |
AsyncThunkAction<TPayload, TThunkArg> | asyncThunkAction | The async thunk action to dispatch. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
IEnumerator | The coroutine. |
Type Parameters
Name | Description |
---|---|
TPayload | The type of the payload (the result of the thunk). |
TThunkArg | The type of the argument to pass to the thunk. |
DispatchAsyncThunkCoroutine<TPayload, TThunkArg>(Store, AsyncThunkAction<TPayload, TThunkArg>, CancellationToken)
Dispatches an async thunk action.
This method will dispatch the pending action, then call the thunk, and finally dispatch the fulfilled or rejected action based on the result of the thunk.
Declaration
public static Coroutine DispatchAsyncThunkCoroutine<TPayload, TThunkArg>(this Store store, AsyncThunkAction<TPayload, TThunkArg> asyncThunkAction, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Store | store | The store to dispatch the action to. |
AsyncThunkAction<TPayload, TThunkArg> | asyncThunkAction | The async thunk action to dispatch. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Coroutine | The coroutine. |
Type Parameters
Name | Description |
---|---|
TPayload | The type of the payload (the result of the thunk). |
TThunkArg | The type of the argument to pass to the thunk. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the store is null. |
ArgumentNullException | Thrown when the asyncThunkAction is null. |
DispatchAsyncThunk<TPayload, TThunkArg>(Store, AsyncThunkAction<TPayload, TThunkArg>, CancellationToken)
Dispatches an async thunk action.
This method will dispatch the pending action, then call the thunk, and finally dispatch the fulfilled or rejected action based on the result of the thunk.
Declaration
public static Task DispatchAsyncThunk<TPayload, TThunkArg>(this Store store, AsyncThunkAction<TPayload, TThunkArg> asyncThunkAction, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Store | store | The store to dispatch the action to. |
AsyncThunkAction<TPayload, TThunkArg> | asyncThunkAction | The async thunk action to dispatch. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TPayload | The type of the payload (the result of the thunk). |
TThunkArg | The type of the argument to pass to the thunk. |
Remarks
Dispatching an async thunk action with this method invloves the use of async/await. If your target platform doesn't support async/await, you can use DispatchAsyncThunkCoroutine<TPayload, TThunkArg>(Store, AsyncThunkAction<TPayload, TThunkArg>, CancellationToken) instead.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the store is null. |
ArgumentNullException | Thrown when the asyncThunkAction is null. |