gpui: notifications now takes an entity instead of a model

Piotr Osiewicz created

Change summary

crates/gpui2/src/app/test_context.rs | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

Detailed changes

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
     }