Show / Hide Table of Contents

Interface IStore<TState>

Representation of a specific store operating within the context of the application. The store can dispatch actions, store, update, and reduce state.

Namespace: BlazorFocused
Assembly: BlazorFocused.Store.dll
Syntax
public interface IStore<TState>
    where TState : class
Type Parameters
Name Description
TState

Original state within the store

Methods

| Improve this Doc View Source

Dispatch<TAction>()

Sends registered action to the store to operate on current state

Declaration
void Dispatch<TAction>()
    where TAction : IAction<TState>
Type Parameters
Name Description
TAction

Action registered in store See IAction<TState>

| Improve this Doc View Source

Dispatch<TAction, TInput>(TInput)

Sends registered action to the store to operate on current state

Declaration
void Dispatch<TAction, TInput>(TInput input)
    where TAction : IAction<TState, TInput>
Parameters
Type Name Description
TInput input
Type Parameters
Name Description
TAction

Action registered in store Input object sent at time of execution See IAction<TState, TInput>

TInput
| Improve this Doc View Source

DispatchAsync<TActionAsync>()

Sends registered asynchronous action to the store to operate on current state

Declaration
ValueTask DispatchAsync<TActionAsync>()
    where TActionAsync : IActionAsync<TState>
Returns
Type Description
ValueTask

Awaitable task

Type Parameters
Name Description
TActionAsync

Asynchronous action registered in store See IActionAsync<TState>

| Improve this Doc View Source

DispatchAsync<TActionAsync, TInput>(TInput)

Declaration
ValueTask DispatchAsync<TActionAsync, TInput>(TInput input)
    where TActionAsync : IActionAsync<TState, TInput>
Parameters
Type Name Description
TInput input
Returns
Type Description
ValueTask
Type Parameters
Name Description
TActionAsync
TInput
| Improve this Doc View Source

GetState()

Returns current value of the state within the current store

Declaration
TState GetState()
Returns
Type Description
TState

Current state of the store

| Improve this Doc View Source

Reduce<TReducer, TOutput>(Action<TOutput>)

Retrieves reduced/transformed version of original store state

Declaration
void Reduce<TReducer, TOutput>(Action<TOutput> action)
    where TReducer : class, IReducer<TState, TOutput> where TOutput : class
Parameters
Type Name Description
Action<TOutput> action

Performed when initial or future reduced value of state is received

Type Parameters
Name Description
TReducer

Reducer class peforming the reduction

TOutput

Reduced/transformed state

Remarks

When inside a Blazor component, this method will usually end with StateHasChanged() to update consumer components dependent upon that state (ComponentBase.StateHasChanged)

| Improve this Doc View Source

SetState(TState)

Updates current state of store

Declaration
void SetState(TState updatedState)
Parameters
Type Name Description
TState updatedState

New value of store state

| Improve this Doc View Source

SetState(Func<TState, TState>)

Updates current state of store

Declaration
void SetState(Func<TState, TState> updateFunction)
Parameters
Type Name Description
Func<TState, TState> updateFunction

Inline function used to update state value

| Improve this Doc View Source

Subscribe(Action<TState>)

Subscribes to current and future values of store state

Declaration
void Subscribe(Action<TState> action)
Parameters
Type Name Description
Action<TState> action

Peformed when initial state or updates are received

Remarks

When inside a Blazor component, this method will usually end with StateHasChanged() to update consumer components dependent upon that state (ComponentBase.StateHasChanged)

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX