28 lines
848 B
TypeScript
28 lines
848 B
TypeScript
import { trait } from "@thilawyn/thilatrait"
|
|
import { mapValues } from "lodash-es"
|
|
import { makeObservable } from "mobx"
|
|
import { z } from "zod"
|
|
|
|
|
|
export const ObservableSchemable = trait(Parent => {
|
|
abstract class ObservableSchemable extends Parent {
|
|
abstract readonly schema: z.ZodObject<
|
|
z.ZodRawShape,
|
|
z.UnknownKeysParam,
|
|
z.ZodTypeAny,
|
|
z.objectOutputType<z.ZodRawShape, z.ZodTypeAny, z.UnknownKeysParam>,
|
|
z.objectInputType<z.ZodRawShape, z.ZodTypeAny, z.UnknownKeysParam>
|
|
>
|
|
|
|
// constructor(...args: any[]) {
|
|
// super(...args)
|
|
|
|
// makeObservable(this,
|
|
// mapValues(this.schema.shape, () => observable) as AnnotationsMap<$Config["values"], never>
|
|
// )
|
|
// }
|
|
}
|
|
|
|
return ObservableSchemable
|
|
})
|