Closed andrewbaxter closed 12 months ago
@andrewbaxter Hey is my discussion post related to what you're talking about? https://github.com/sycamore-rs/sycamore/discussions/615
I think your case is more complex, this was about modifying a simple list of values, rather than nesting (maybe?). But it is related... I wanted to store heavier objects too and I think in my original use case I wanted to nest things.
Now that #626 has been merged, updating a Vec
or other container inside a Signal
is extremely simple. Simply use .update(|value| ...)
where value
is a mutable reference to the value inside the Signal
. I think this can be closed now since the examples (in particular, todomvc and js-framework-benchmark) have both been updated to use this instead of cloning and pushing.
All the examples/documentation related to iterables use static data. My guess is that you can't mutate a collection, you need to clone it, modify the clone, and replace the original.