Skip to content

Passing rich objects as page params from load #3387

Answered by jmakeig
jmakeig asked this question in Q&A
Discussion options

You must be logged in to vote

Apparently my error was between the chair and the keyboard.

After some fiddling, here’s a summary of how I successfully wired everything up. The key insight was that XState actors (e.g. interpreted machines) are also Svelte stores. Passing stores between components allows you to let XState handle the relationships between the backing state, for example, spawning child machines. As @Rich-Harris’s comment above indicates, it’s possible to hydrate server-generated content with “real” objects, not just JSON-serializable data. 🤯

The use case here is a classic collection-detail. Initially you get a list of available items. Selecting one shows its detail and allows the user to edit.

This is most…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jmakeig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant