AggregateStore<TData extends Object, TEvent extends Object, TValue extends Object, TId extends AggregateId, TState extends AggregateState<TValue>, TAggregate extends Aggregate<TEvent, TValue, TId, TState>> class

AggregateStore store maintains Aggregate instances.

This decouples loading AggregateState from Aggregate allowing different strategies to be implemented like building state directly from the StreamEventStore by folding every event on some initial condition, or loading state from a snapshot of last stored AggregateState.

This class implements AggregateCreator as default method.

Constructors

AggregateStore(StreamEventStore events, {EventSerializer<TEvent>? serializer, AggregateCreator<TEvent, TValue, TId, TState, TAggregate>? onNew, AggregateStateStorage<TValue, TState>? states})
Default constructor.

Properties

events StreamEventStore
StreamEventStore loading and storing StreamEvents
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
states AggregateStateStorage<TValue, TState>?
AggregateStateStore loading AggregateStates
no setter

Methods

delete(TAggregate aggregate) Future<AggregateStateResult<TEvent, TValue, TId, TState>>
Save AggregateState of given aggregate
load(TId id) Future<TAggregate>
Load AggregateState into given aggregate from this store If aggregate does not exist a AggregateNotFound is thrown.
loadState(TId id, [TValue? value]) FutureOr<TState>
Load state for Aggregate with given id.
newInstance(TId id, [TState? state]) → TAggregate
Create new Aggregate instance of type TAggregate
newStateInstance([TValue? value]) → TState
Create new AggregateState instance of type TState
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(TAggregate aggregate) Future<AggregateStateResult<TEvent, TValue, TId, TState>>
Save AggregateState of given aggregate to this store
toStreamEvent(TEvent event, int position) StreamEvent
toString() String
A string representation of this object.
inherited
truncate(TAggregate aggregate) Future<AggregateStateResult<TEvent, TValue, TId, TState>>
Truncate AggregateState of given aggregate

Operators

operator ==(Object other) bool
The equality operator.
inherited