This commit is contained in:
Mikayla 2023-11-06 11:18:56 -08:00
parent d66ed4310f
commit 75a80811b3
No known key found for this signature in database
5 changed files with 15 additions and 2 deletions

View file

@ -706,6 +706,7 @@ impl AppContext {
}
/// Access the global of the given type. Panics if a global for that type has not been assigned.
#[track_caller]
pub fn global<G: 'static>(&self) -> &G {
self.globals_by_type
.get(&TypeId::of::<G>())
@ -722,6 +723,7 @@ impl AppContext {
}
/// Access the global of the given type mutably. Panics if a global for that type has not been assigned.
#[track_caller]
pub fn global_mut<G: 'static>(&mut self) -> &mut G {
let global_type = TypeId::of::<G>();
self.push_effect(Effect::NotifyGlobalObservers { global_type });