[fabric/domain] Add Projection interface to handle model projection from events
This commit is contained in:
parent
c9a061419c
commit
8c6f043f86
13
packages/fabric/domain/src/projections/projection.ts
Normal file
13
packages/fabric/domain/src/projections/projection.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { VariantTag } from "@fabric/core";
|
||||
import { Event } from "../events/event.js";
|
||||
import { StoredEvent } from "../events/stored-event.js";
|
||||
import { Model, ModelToType } from "../models/model.js";
|
||||
|
||||
export interface Projection<TModel extends Model, TEvents extends Event> {
|
||||
model: TModel;
|
||||
events: TEvents[VariantTag][];
|
||||
projection: (
|
||||
event: StoredEvent<TEvents>,
|
||||
model?: ModelToType<TModel>,
|
||||
) => ModelToType<TModel>;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user