Use a WeakViewHandle in Client for view message handlers
This commit is contained in:
@@ -4156,9 +4156,24 @@ impl AnyWeakViewHandle {
|
||||
self.view_id
|
||||
}
|
||||
|
||||
fn is<T: 'static>(&self) -> bool {
|
||||
TypeId::of::<T>() == self.view_type
|
||||
}
|
||||
|
||||
pub fn upgrade(&self, cx: &impl BorrowAppContext) -> Option<AnyViewHandle> {
|
||||
cx.read_with(|cx| cx.upgrade_any_view_handle(self))
|
||||
}
|
||||
|
||||
pub fn downcast<T: View>(self) -> Option<WeakViewHandle<T>> {
|
||||
if self.is::<T>() {
|
||||
Some(WeakViewHandle {
|
||||
any_handle: self,
|
||||
view_type: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for AnyWeakViewHandle {
|
||||
|
||||
Reference in New Issue
Block a user