Class ReducerAggregateRootStateProvider<TState>
- Namespace
- Cratis.Chronicle.Aggregates
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IAggregateRootStateProvider<TState> using a reducer.
public class ReducerAggregateRootStateProvider<TState> : IAggregateRootStateProvider<TState>
Type Parameters
TState
Type of state for the aggregate root.
- Inheritance
-
ReducerAggregateRootStateProvider<TState>
- Implements
-
IAggregateRootStateProvider<TState>
- Inherited Members
Remarks
Initializes a new instance of the ReducerAggregateRootStateProvider<TState> class.
Constructors
ReducerAggregateRootStateProvider(IAggregateRootContext, IReducerHandler, IServiceProvider)
Represents an implementation of IAggregateRootStateProvider<TState> using a reducer.
public ReducerAggregateRootStateProvider(IAggregateRootContext aggregateRootContext, IReducerHandler reducer, IServiceProvider serviceProvider)
Parameters
aggregateRootContext
IAggregateRootContextThe IAggregateRootContext the state is for.
reducer
IReducerHandlerIReducerHandler to use for creating the state.
serviceProvider
IServiceProviderThe IServiceProvider to create the actual instance of the reducer.
Remarks
Initializes a new instance of the ReducerAggregateRootStateProvider<TState> class.
Methods
Dehydrate()
Dehydrate any state.
public Task Dehydrate()
Returns
- Task
Awaitable task.
Provide()
Handle state for an AggregateRoot.
public Task<TState?> Provide()
Returns
- Task<TState>
State provided.
Update(TState?, IEnumerable<object>)
Update the state of an AggregateRoot with events.
public Task<TState?> Update(TState? initialState, IEnumerable<object> events)
Parameters
initialState
TStateThe initial state to update from.
events
IEnumerable<object>The events to update with.
Returns
- Task<TState>
Updated state.