From d5a1de05a707c93f5a877173b79de7c831094ca9 Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Wed, 3 Feb 2021 16:32:07 +0100 Subject: [PATCH] Handle screens dropping their sender --- src/navigator/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/navigator/mod.rs b/src/navigator/mod.rs index ffeb443..70b434a 100644 --- a/src/navigator/mod.rs +++ b/src/navigator/mod.rs @@ -37,7 +37,9 @@ impl NavigationHandle { pub async fn push + 'static>(&self, input: I) -> Option { let navigator = self.unwrap_navigator(); let receiver = navigator.push::(input); - receiver.await.expect("The sender to send the result of a screen was dropped.") + + // If the sender is dropped, return None. + receiver.await.unwrap_or(None) } /// Go back to the previous screen optionally returning something. @@ -137,7 +139,8 @@ impl Navigator { self.clear_old_widgets(); } - receiver.await.expect("The sender to send the result of a screen was dropped.") + // We ignore the case, if a sender is dropped. + receiver.await.unwrap_or(None) }