YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.
https://syncedstore.org
MIT License
1.73k stars 52 forks source link

Assign boxed objects #104

Open canadaduane opened 1 year ago

canadaduane commented 1 year ago

I have a typescript type that has several variants:


type PresenceType =
  | {
      status: "offline"
    }
  | {
      eventId: string
      status: "in-class"
    }
  | {
      eventId: string | null
      gameId: string | null
      status: "in-play"
    }

const store = syncedStore({
  presence: boxed({
    status: "offline",
  }) as Box<PresenceType>,
})

Now how do I assign this boxed object? The following is not allowed due to presence being read-only:

store.presence = boxed({ status: "in-class", eventId: "xyz" })