feat: add use_desktop_context hook
This commit is contained in:
1 parent
e4eb982a36
commit
366cf75887
2 files changed
+13
-7
No files matched your search
@@ -1,3 +1,6 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use dioxus_core::ScopeState;
|
||||
use wry::application::event_loop::EventLoopProxy;
|
||||
|
||||
use crate::UserWindowEvent;
|
||||
@@ -50,3 +53,10 @@ impl DesktopContext {
|
||||
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
|
||||
}
|
||||
}
|
||||
|
||||
/// use this function can get the `DesktopContext` context.
|
||||
pub fn use_desktop_context(cx: &ScopeState) -> &Rc<DesktopContext> {
|
||||
cx.use_hook(|_| cx.consume_context::<DesktopContext>())
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
}
|
||||
Reference in new issue
Block a user