Replies: 1 comment
-
Hi, and thanks for the question! Indeed, a button currently stores a If you don't care about the recursive situation, you can wrap a |
Beta Was this translation helpful? Give feedback.
-
Hi, and thanks for the question! Indeed, a button currently stores a If you don't care about the recursive situation, you can wrap a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to have a button that mutates some data, under the context of a state manager. I wrote a simple state manager that works kind of like a state machine with changes in state happening through navigating the UI, and some functions related to mutating the data requires a mutable reference to self, which requires a mutable variable and a mutable reference, which cannot be obtained inside a plain
Fn
. Is there a way around this:Note: I did try wrapping it in an
Rc
ofCell
, it did work until I encounteredclosure may outlive the current function, but it borrows \
state manager variable name`, which is owned by the current function.Using
movewould work, but one would need to make a different clone of the
Rc` per closure, which is kind of clunky.Beta Was this translation helpful? Give feedback.
All reactions