0.1.15 #16

Merged
Thilawyn merged 12 commits from next into master 2024-09-04 00:33:45 +02:00
Showing only changes of commit a6ef4defe6 - Show all commits

View File

@@ -1,5 +1,5 @@
import { Schema as S } from "@effect/schema" 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 type { Simplify } from "type-fest"
import { MutableTaggedClass, toJsonifiable } from "./Schema" import { MutableTaggedClass, toJsonifiable } from "./Schema"
import { ObservableClass } from "./Schema/MobX" import { ObservableClass } from "./Schema/MobX"
@@ -18,12 +18,24 @@ type TestB = {
type Merged = Simplify<ExtendAll<[TestA, TestB]>> type Merged = Simplify<ExtendAll<[TestA, TestB]>>
class User extends MutableTaggedClass<User>()("User", {
const UserSchema = MutableTaggedClass<User>()("User", {
id: S.BigIntFromSelf, id: S.BigIntFromSelf,
role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")), role: S.Union(S.Literal("BasicUser"), S.Literal("Admin")),
}).pipe( }).pipe(
ObservableClass() ObservableClass()
) {} )
class User extends UserSchema {
constructor(...args: ConstructorParameters<typeof UserSchema>) {
super(...args)
makeObservable(this, { idAsString: computed })
}
get idAsString() {
return this.id.toString()
}
}
const JsonifiableUser = User.pipe( const JsonifiableUser = User.pipe(
toJsonifiable(S.Struct({ toJsonifiable(S.Struct({