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
+4 -3
View File
@@ -324,9 +324,10 @@ impl Editor {
) -> Self {
let display_map =
cx.add_model(|cx| DisplayMap::new(buffer.clone(), settings.borrow().clone(), None, cx));
cx.observe(&buffer, Self::on_buffer_changed);
cx.subscribe(&buffer, Self::on_buffer_event);
cx.observe(&display_map, Self::on_display_map_changed);
cx.observe(&buffer, Self::on_buffer_changed).detach();
cx.subscribe(&buffer, Self::on_buffer_event).detach();
cx.observe(&display_map, Self::on_display_map_changed)
.detach();
let mut next_selection_id = 0;
let selection_set_id = buffer.update(cx, |buffer, cx| {