Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign boxed objects #104

Open
canadaduane opened this issue May 5, 2023 · 0 comments
Open

Assign boxed objects #104

canadaduane opened this issue May 5, 2023 · 0 comments

Comments

@canadaduane
Copy link

canadaduane commented May 5, 2023

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" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant