Allow subscription/notification to be cancelled by dropping the returned Subscription

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-08-23 15:54:24 -07:00
co-authored by Nathan Sobo
parent f4847bd38f
commit 6df80d94ad
8 changed files with 228 additions and 110 deletions
+3 -2
View File
@@ -61,7 +61,8 @@ impl ThemeSelector {
cx: &mut ViewContext<Self>,
) -> Self {
let query_buffer = cx.add_view(|cx| Editor::single_line(settings.clone(), cx));
cx.subscribe(&query_buffer, Self::on_query_editor_event);
cx.subscribe(&query_buffer, Self::on_query_editor_event)
.detach();
let mut this = Self {
settings,
@@ -86,7 +87,7 @@ impl ThemeSelector {
cx,
)
});
cx.subscribe(&selector, Self::on_event);
cx.subscribe(&selector, Self::on_event).detach();
selector
});
}