Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: notifications now takes an entity instead of a model
Piotr Osiewiczeb9959a0cf58
diff --git a/crates/gpui2/src/app/test_context.rs b/crates/gpui2/src/app/test_context.rsindex 940492573f0..7b6acad586e 100644--- a/crates/gpui2/src/app/test_context.rs+++ b/crates/gpui2/src/app/test_context.rs@@ -1,8 +1,9 @@use crate::{div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext,- BackgroundExecutor, Context, Div, EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent,- Keystroke, Model, ModelContext, Render, Result, Task, TestDispatcher, TestPlatform, TestWindow,- View, ViewContext, VisualContext, WindowContext, WindowHandle, WindowOptions,+ BackgroundExecutor, Context, Div, Entity, EventEmitter, ForegroundExecutor, InputEvent,+ KeyDownEvent, Keystroke, Model, ModelContext, Render, Result, Task, TestDispatcher,+ TestPlatform, TestWindow, View, ViewContext, VisualContext, WindowContext, WindowHandle,+ WindowOptions,};use anyhow::{anyhow, bail};use futures::{Stream, StreamExt};@@ -296,21 +297,19 @@ impl TestAppContext {.unwrap()}- pub fn notifications<T: 'static>(&mut self, entity: &Model<T>) -> impl Stream<Item = ()> {+ pub fn notifications<T: 'static>(&mut self, entity: &impl Entity<T>) -> impl Stream<Item = ()> {let (tx, rx) = futures::channel::mpsc::unbounded();-- entity.update(self, move |_, cx: &mut ModelContext<T>| {+ self.update(|cx| {cx.observe(entity, {let tx = tx.clone();- move |_, _, _| {+ move |_, _| {let _ = tx.unbounded_send(());}}).detach();-- cx.on_release(move |_, _| tx.close_channel()).detach();+ cx.observe_release(entity, move |_, _| tx.close_channel())+ .detach()});-rx}