refactor: remove duplicate code and fmt

This commit is contained in:
xuu
2023-07-22 08:52:15 -06:00
parent 0f665d3484
commit 70c6996f39
16 changed files with 229 additions and 306 deletions

View File

@@ -238,28 +238,29 @@ func AsEvent[T any](e T) Event {
return &asEvent[T]{payload: e}
}
type asEvent [T any] struct {
type asEvent[T any] struct {
payload T
IsEvent
}
func (e asEvent[T]) Payload() T {
return e.payload
}
type AGG interface{ApplyEvent(...Event)}
type AGG interface{ ApplyEvent(...Event) }
func AsAggregate[T AGG](e T) Aggregate {
return &asAggregate[T]{payload: e}
}
type asAggregate [T AGG] struct {
type asAggregate[T AGG] struct {
payload T
IsAggregate
}
func (e *asAggregate[T]) Payload() T {
return e.payload
}
func (e *asAggregate[T]) ApplyEvent(lis ...Event) {
e.payload.ApplyEvent(lis...)
}
}