This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Schema as S } from "@effect/schema"
|
||||
import { reaction, runInAction } from "mobx"
|
||||
import { pipe } from "remeda"
|
||||
import { MobXObservable } from "./MobXObservable"
|
||||
import { MutableTaggedClass } from "./MutableTaggedClass"
|
||||
@@ -12,13 +13,17 @@ class User extends pipe(
|
||||
MobXObservable,
|
||||
) {}
|
||||
|
||||
const user1 = new User({ id: 1n, role: "BasicUser" })
|
||||
user1.id = 1n
|
||||
const user1 = new User({ id: -1n, role: "BasicUser" })
|
||||
reaction(() => user1.id, id => console.log(`user1 id changed: ${ id }`))
|
||||
|
||||
|
||||
class Admin extends User.extend<Admin>("Admin")({
|
||||
// role: S.Literal("Admin")
|
||||
}) {}
|
||||
|
||||
const user2 = new Admin({ id: 2n, role: "Admin" })
|
||||
user2.id = 2n
|
||||
const user2 = new Admin({ id: -1n, role: "Admin" })
|
||||
reaction(() => user2.id, id => console.log(`user2 id changed: ${ id }`))
|
||||
|
||||
|
||||
runInAction(() => { user1.id = 1n })
|
||||
runInAction(() => { user2.id = 2n })
|
||||
|
||||
Reference in New Issue
Block a user