Skip to content

Is there a pattern for view() as method on Rc<RefCell<Something>>? #1483

Answered by tarkah
sowbug asked this question in Q&A
Discussion options

You must be logged in to vote

In 99% of cases, you absolutely shouldn't need interior mutability anywhere across the app. I highly recommend targeting master instead of 0.4 and using the new pure API. This will make things a lot more simple and it's more natural as view(&self) is now immutable.

Here is a relevant snippet for you (using iced from master / pure), where you can hold an array of some state for an iterable component of your app:

use iced::widget::{column, container};
use iced::{executor, Application, Command, Element, Length, Settings, Theme};

use self::thing::Thing;

fn main() {
    App::run(Settings::default()).unwrap();
}

#[derive(Debug, Clone)]
enum Message {
    Thing(usize, thing::Message),
}

struct 

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sowbug
Comment options

@tarkah
Comment options

Answer selected by sowbug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants