diff --git a/src/tests.ts b/src/tests.ts index e23104f..de20458 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -1,5 +1,5 @@ import { Schema as S } from "@effect/schema" -import { reaction, runInAction } from "mobx" +import { computed, makeObservable, reaction, runInAction } from "mobx" import type { Simplify } from "type-fest" import { MutableTaggedClass, toJsonifiable } from "./Schema" import { ObservableClass } from "./Schema/MobX" @@ -18,12 +18,24 @@ type TestB = { type Merged = Simplify> -class User extends MutableTaggedClass()("User", { + +const UserSchema = MutableTaggedClass()("User", { id: S.BigIntFromSelf, role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")), }).pipe( ObservableClass() -) {} +) + +class User extends UserSchema { + constructor(...args: ConstructorParameters) { + super(...args) + makeObservable(this, { idAsString: computed }) + } + + get idAsString() { + return this.id.toString() + } +} const JsonifiableUser = User.pipe( toJsonifiable(S.Struct({