Snapshot
Represent the public state of an object at a point in time
Object.fromSnapshot(obj.snapshot()) == objtype State = {
id: string;
creditPoints: number;
schedule: Schedule;
};
type Snapshot = {
id: string;
creditPoints: number;
schedule: GetSnapshot<Schedule>;
};
export class Student extends Entity<State, Snapshot> {
static fromSnapshot(snapshot: Snapshot): Student {
return new Student({
id: snapshot.id,
creditPoints: snapshot.creditPoints,
schedule: Schedule.fromSnapshot(snapshot)
})
}
snapshot(): Snapshot {
return {
id: this._state.id,
creditPoints: this._state.creditPoints,
schedule: this._state.schedule.snapshot(),
};
}
}Last updated