make desktop compile
This commit is contained in:
1 parent
21b71e992f
commit
3865f44081
27 files changed
+357
-422
No files matched your search
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::await_holding_refcell_ref)]
|
||||
|
||||
use async_trait::async_trait;
|
||||
use dioxus_core::ScopeState;
|
||||
use dioxus_core::prelude::*;
|
||||
use std::future::{Future, IntoFuture};
|
||||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
@@ -34,18 +34,14 @@ type EvalCreator = Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>;
|
||||
/// it. **This applies especially to web targets, where the JavaScript context
|
||||
/// has access to most, if not all of your application data.**
|
||||
#[must_use]
|
||||
pub fn use_eval(cx: &ScopeState) -> &EvalCreator {
|
||||
&*cx.use_hook(|| {
|
||||
let eval_provider = cx
|
||||
.consume_context::<Rc<dyn EvalProvider>>()
|
||||
.expect("evaluator not provided");
|
||||
pub fn eval_provider() -> EvalCreator {
|
||||
let eval_provider = consume_context::<Rc<dyn EvalProvider>>().expect("evaluator not provided");
|
||||
|
||||
Rc::new(move |script: &str| {
|
||||
eval_provider
|
||||
.new_evaluator(script.to_string())
|
||||
.map(UseEval::new)
|
||||
}) as Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>
|
||||
})
|
||||
Rc::new(move |script: &str| {
|
||||
eval_provider
|
||||
.new_evaluator(script.to_string())
|
||||
.map(UseEval::new)
|
||||
}) as Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>
|
||||
}
|
||||
|
||||
pub fn eval(script: &str) -> Result<UseEval, EvalError> {
|
||||
|
||||
@@ -9,11 +9,11 @@ macro_rules! impl_event {
|
||||
$(
|
||||
$( #[$attr] )*
|
||||
#[inline]
|
||||
pub fn $name<'a, E: crate::EventReturn<T>, T>(_cx: &'a ::dioxus_core::ScopeState, mut _f: impl FnMut(::dioxus_core::Event<$data>) -> E + 'a) -> ::dioxus_core::Attribute {
|
||||
pub fn $name<E: crate::EventReturn<T>, T>(mut _f: impl FnMut(::dioxus_core::Event<$data>) -> E + 'static) -> ::dioxus_core::Attribute {
|
||||
::dioxus_core::Attribute::new(
|
||||
stringify!($name),
|
||||
_cx.listener(move |e: ::dioxus_core::Event<$data>| {
|
||||
_f(e).spawn(_cx);
|
||||
::dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event<$data>| {
|
||||
_f(e).spawn();
|
||||
}),
|
||||
None,
|
||||
false,
|
||||
@@ -155,7 +155,7 @@ use std::future::Future;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait EventReturn<P>: Sized {
|
||||
fn spawn(self, _cx: &dioxus_core::ScopeState) {}
|
||||
fn spawn(self) {}
|
||||
}
|
||||
|
||||
impl EventReturn<()> for () {}
|
||||
@@ -167,7 +167,7 @@ where
|
||||
T: Future<Output = ()> + 'static,
|
||||
{
|
||||
#[inline]
|
||||
fn spawn(self, cx: &dioxus_core::ScopeState) {
|
||||
cx.spawn(self);
|
||||
fn spawn(self) {
|
||||
dioxus_core::prelude::spawn(self);
|
||||
}
|
||||
}
|
||||
@@ -148,14 +148,13 @@ impl_event! {
|
||||
|
||||
/// ondoubleclick
|
||||
#[inline]
|
||||
pub fn ondoubleclick<'a, E: crate::EventReturn<T>, T>(
|
||||
_cx: &'a ::dioxus_core::ScopeState,
|
||||
mut _f: impl FnMut(::dioxus_core::Event<MouseData>) -> E + 'a,
|
||||
pub fn ondoubleclick<E: crate::EventReturn<T>, T>(
|
||||
mut _f: impl FnMut(::dioxus_core::Event<MouseData>) -> E + 'static,
|
||||
) -> ::dioxus_core::Attribute {
|
||||
::dioxus_core::Attribute::new(
|
||||
"ondblclick",
|
||||
_cx.listener(move |e: ::dioxus_core::Event<MouseData>| {
|
||||
_f(e).spawn(_cx);
|
||||
dioxus_core::AttributeValue::listener(move |e: ::dioxus_core::Event<MouseData>| {
|
||||
_f(e).spawn();
|
||||
}),
|
||||
None,
|
||||
false,
|
||||
|
||||
Reference in new issue
Block a user