Okay, I am pretty sure this is an error from my side, but I just can't seem to figure out what the issue is. I've tried comparing to multiple examples, and some other projects I found using Iced. Problem is it seem never to call my Foo::load() method, thus never calling in my match inside update. Anyone know what I am doing wrong here?
```rust
pub fn run() {
let mut settings = Settings::default();
Ajour::run(settings);
}
pub enum Message {
Refresh(String),
}
struct Foo {
}
impl Foo {
async fn load() -> String {
Ok(String::from("Hello"))
}
}
struct Ajour {
addon: String,
}
impl Default for Ajour {
fn default() -> Self {
Self {
addons: Default::default(),
}
}
}
impl Application for Ajour {
type Executor = executor::Null;
type Message = Message;
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
(
Ajour::default(),
Command::perform(Foo::load(), Message::Refresh),
)
}
fn update(&mut self, message: Message) -> Command<Message> {
match message {
Message::Refresh(_) => {
println!("We fetched addons");
Command::none()
}
}
}
fn view(&mut self) -> Element<Self::Message> {
....
}
}
type Executor = executor::Null;
An executor that drops all the futures, instead of spawning them.
Your Foo::load() future just gets dropped. Try to use iced::executor::Default and it will work.
Haha, jesus. I feel super stupid now.
Thank you for responding so fast @Songtronix.
Most helpful comment
Haha, jesus. I feel super stupid now.
Thank you for responding so fast @Songtronix.