From 9fe4a14f733589dffc973387f7924cea812dcb68 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 21 Apr 2025 16:41:15 -0600 Subject: [PATCH] Add a brief description of GPUI 2->GPUI 3 changes to `.rules` (#29180) Release Notes: - N/A --- .rules | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.rules b/.rules index c887db0358..e36c7db343 100644 --- a/.rules +++ b/.rules @@ -109,3 +109,13 @@ When a view's state has changed in a way that may affect its rendering, it shoul While updating an entity (`cx: Context`), it can emit an event using `cx.emit(event)`. Entities register which events they can emit by declaring `impl EventEmittor for EntityType {}`. Other entities can then register a callback to handle these events by doing `cx.subscribe(other_entity, |this, other_entity, event, cx| ...)`. This will return a `Subscription` which deregisters the callback when dropped. Typically `cx.subscribe` happens when creating a new entity and the subscriptions are stored in a `_subscriptions: Vec` field. + +## Recent API changes + +GPUI has had some changes to its APIs. Always write code using the new APIs: + +* `spawn` methods now take async closures (`AsyncFn`), and so should be called like `cx.spawn(async move |cx| ...)`. +* Use `Entity`. This replaces `Model` and `View` which longer exists and should NEVER be used. +* Use `App` references. This replaces `AppContext` which no longer exists and should NEVER be used. +* Use `Context` references. This replaces `ModelContext` which no longer exists and should NEVER be used. +* `Window` is now passed around explicitly. The new interface adds a `Window` reference parameter to some methods, and adds some new "*_in" methods for plumbing `Window`. The old types `WindowContext` and `ViewContext` should NEVER be used.