dice could be downstream from rolls
dice
rolls
This is how I'd do it in the next version of StateAdapt
const { draw, reset, $state: rolls } = adapt([0], { draw: state => [...state, (math random stuff)], }) const dice = $derived(rolls[rolls.length - 1]);
Just an idea. Probably on dangerous ground with the $state keyword. But it works
Thank you for the feedback. Managing arrays as a state is something that I'm exploring more in order to identify the "best way" to manage them. For example, i want to replace adding item into an array with :
rolls = [...rolls, dice]
I will monitor the side effects. I want to explore more "Fine grained reactivity" https://www.youtube.com/watch?v=gGwnF-lxS_Q&t=313s
For my own future reference svelte-5-preview.vercel.app/#H4sIA...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
dicecould be downstream fromrollsThis is how I'd do it in the next version of StateAdapt
Just an idea. Probably on dangerous ground with the $state keyword. But it works
Thank you for the feedback.
Managing arrays as a state is something that I'm exploring more in order to identify the "best way" to manage them.
For example, i want to replace adding item into an array with :
I will monitor the side effects.
I want to explore more "Fine grained reactivity" https://www.youtube.com/watch?v=gGwnF-lxS_Q&t=313s
For my own future reference svelte-5-preview.vercel.app/#H4sIA...