Implement ClientSchedule state tracking class
Write the logic of keeping track of location modifications and applying updates from the server into the ClientSchedule class. This should serve as the foundation for replacing the prototype in-component update logic which have turned into an unmaintainable spagetti.
This commit is contained in:
parent
aa52a6c651
commit
e100555304
5 changed files with 1005 additions and 1 deletions
|
@ -8,7 +8,7 @@ export const entityLivingSchema = z.object({
|
|||
updatedAt: z.string(),
|
||||
deleted: z.optional(z.literal(false)),
|
||||
});
|
||||
export type EnityLiving = z.infer<typeof entityLivingSchema>;
|
||||
export type EntityLiving = z.infer<typeof entityLivingSchema>;
|
||||
|
||||
export const entityToombstoneSchema = z.object({
|
||||
id: idSchema,
|
||||
|
@ -20,6 +20,9 @@ export type EntityToombstone = z.infer<typeof entityToombstoneSchema>;
|
|||
export const entitySchema = z.discriminatedUnion("deleted", [entityLivingSchema, entityToombstoneSchema]);
|
||||
export type Entity = z.infer<typeof entitySchema>;
|
||||
|
||||
export type Living<T extends Entity> = Extract<T, { deleted?: false }>;
|
||||
export type Tombstone<T extends Entity> = Extract<T, { deleted: true }>;
|
||||
|
||||
export function defineEntity<T extends {}>(fields: T) {
|
||||
return z.discriminatedUnion("deleted", [z.extend(entityLivingSchema, fields), entityToombstoneSchema]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue