From 1a8e909a3893c2f711d011ac585f6b769527d140 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 20 Apr 2021 10:43:13 -0600 Subject: [PATCH] Ensure we remove broadcast channels after all conditions resolve Co-Authored-By: Max Brunsfeld Co-Authored-By: Antonio Scandurra --- gpui/src/app.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gpui/src/app.rs b/gpui/src/app.rs index a91a861eef1d188635a13accfd2461534cc9af31..f7dfd9cedbc362fcfd43d6817b388d28b8c72f60 100644 --- a/gpui/src/app.rs +++ b/gpui/src/app.rs @@ -3332,6 +3332,10 @@ mod tests { model.update(&mut app, |model, ctx| model.inc(ctx)); assert_eq!(poll_once(&mut condition2).await, Some(())); + + // Broadcast channel should be removed if no conditions remain on next notification. + model.update(&mut app, |_, ctx| ctx.notify()); + app.update(|ctx| assert!(ctx.async_observations.get(&model.id()).is_none())); }); } @@ -3409,6 +3413,10 @@ mod tests { view.update(&mut app, |view, ctx| view.inc(ctx)); assert_eq!(poll_once(&mut condition2).await, Some(())); + + // Broadcast channel should be removed if no conditions remain on next notification. + view.update(&mut app, |_, ctx| ctx.notify()); + app.update(|ctx| assert!(ctx.async_observations.get(&view.id()).is_none())); }); }