You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
I'm not sure how to go about adding mutable shared state. I feel like this is a very common thing to want in a UI app, but I can't find it in the examples. I'm suspicious the solution involves Rc<RefCell<T>>, but am not sure how to do it. Eg:
let state = Rc::new(RefCell::new(state));// Interior mutability to solve this?let btn1 = Button::new_with_label("1");
btn1.connect_clicked(|_| {
state.borrow_mut().value1 = true;});let btn2 = Button::new_with_label("2");
btn2.connect_clicked(|_| {
state.borrow_mut().value2 = true;});
The text was updated successfully, but these errors were encountered:
I'm not sure how to go about adding mutable shared state. I feel like this is a very common thing to want in a UI app, but I can't find it in the examples. I'm suspicious the solution involves
Rc<RefCell<T>>
, but am not sure how to do it. Eg:The text was updated successfully, but these errors were encountered: