SyncedStore icon indicating copy to clipboard operation
SyncedStore copied to clipboard

Assign boxed objects

Open canadaduane opened this issue 1 year ago • 0 comments

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" })

canadaduane avatar May 05 '23 14:05 canadaduane