Skip to content

Commit

Permalink
fix multi_webview
Browse files Browse the repository at this point in the history
  • Loading branch information
LegitCamper committed Nov 2, 2024
1 parent c4046c7 commit bdc4d4f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/multi_webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl App {
}

fn update(&mut self, message: Message) -> Task<Message> {
match message {
let mut tasks = Vec::new();
tasks.push(match message {
Message::WebView(msg) => self.webview.update(msg),
Message::CreatedNewWebView(view_id) => {
if self.webviews.0 == None {
Expand All @@ -57,7 +58,14 @@ impl App {
}
Task::none()
}
});
if let Some(view_0) = self.webviews.0 {
tasks.push(self.webview.update(Action::Update(view_0)));
}
if let Some(view_1) = self.webviews.1 {
tasks.push(self.webview.update(Action::Update(view_1)));
}
Task::batch(tasks)
}

fn view(&self) -> Element<Message> {
Expand All @@ -83,8 +91,8 @@ impl App {
}

fn subscription(&self) -> Subscription<Message> {
time::every(Duration::from_millis(10))
Subscription::batch([time::every(Duration::from_millis(10))
.map(|_| Action::UpdateAll)
.map(Message::WebView)
.map(Message::WebView)])
}
}

0 comments on commit bdc4d4f

Please sign in to comment.