Struct dioxus::prelude::RuntimeGuard
source · pub struct RuntimeGuard(/* private fields */);
Expand description
A guard for a new runtime. This must be used to override the current runtime when importing components from a dynamic library that has it’s own runtime.
use dioxus::prelude::*;
fn main() {
let virtual_dom = VirtualDom::new(app);
}
fn app() -> Element {
rsx!{ Component { runtime: Runtime::current().unwrap() } }
}
// In a dynamic library
#[derive(Props, Clone)]
struct ComponentProps {
runtime: std::rc::Rc<Runtime>,
}
impl PartialEq for ComponentProps {
fn eq(&self, _other: &Self) -> bool {
true
}
}
fn Component(cx: ComponentProps) -> Element {
use_hook(|| {
let _guard = RuntimeGuard::new(cx.runtime.clone());
});
rsx! { div {} }
}
Implementations§
source§impl RuntimeGuard
impl RuntimeGuard
sourcepub fn new(runtime: Rc<Runtime>) -> RuntimeGuard
pub fn new(runtime: Rc<Runtime>) -> RuntimeGuard
Create a new runtime guard that sets the current Dioxus runtime. The runtime will be reset when the guard is dropped
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuntimeGuard
impl RefUnwindSafe for RuntimeGuard
impl Send for RuntimeGuard
impl Sync for RuntimeGuard
impl Unpin for RuntimeGuard
impl UnwindSafe for RuntimeGuard
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.
source§impl<Cfg> TryIntoConfig for Cfg
impl<Cfg> TryIntoConfig for Cfg
source§fn into_config(self) -> Option<Cfg>
fn into_config(self) -> Option<Cfg>
Available on crate feature
launch
only.