From bdc4d4f57a8131624ba22f032d08b015ffd0c617 Mon Sep 17 00:00:00 2001 From: sawyer bristol Date: Sat, 2 Nov 2024 16:25:38 -0600 Subject: [PATCH] fix multi_webview --- examples/multi_webview.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/multi_webview.rs b/examples/multi_webview.rs index 75c34d5..02d258a 100644 --- a/examples/multi_webview.rs +++ b/examples/multi_webview.rs @@ -47,7 +47,8 @@ impl App { } fn update(&mut self, message: Message) -> Task { - 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 { @@ -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 { @@ -83,8 +91,8 @@ impl App { } fn subscription(&self) -> Subscription { - time::every(Duration::from_millis(10)) + Subscription::batch([time::every(Duration::from_millis(10)) .map(|_| Action::UpdateAll) - .map(Message::WebView) + .map(Message::WebView)]) } }