make desktop compile

This commit is contained in:
Evan Almloff committed 2024-01-05 14:39:45 -06:00
1 parent 21b71e992f
commit 3865f44081
27 files changed
+357 -422

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
use dioxus_core::{ScopeState, TaskId};
use dioxus_core::{ScopeState, Task};
pub use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
use std::future::Future;
@@ -87,7 +87,7 @@ pub fn use_coroutine_handle<M: 'static>(cx: &ScopeState) -> Option<&Coroutine<M>
pub struct Coroutine<T> {
tx: UnboundedSender<T>,
task: TaskId,
task: Task,
}
// for use in futures
@@ -103,7 +103,7 @@ impl<T> Clone for Coroutine<T> {
impl<T> Coroutine<T> {
/// Get the ID of this coroutine
#[must_use]
pub fn task_id(&self) -> TaskId {
pub fn task_id(&self) -> Task {
self.task
}
+5 -5
View File
@@ -1,4 +1,4 @@
use dioxus_core::{ScopeState, TaskId};
use dioxus_core::{ScopeState, Task};
use std::{
any::Any,
cell::{Cell, RefCell},
@@ -67,7 +67,7 @@ where
{
struct UseEffect {
needs_regen: bool,
task: Cell<Option<TaskId>>,
task: Cell<Option<Task>>,
dependencies: Vec<Box<dyn Any>>,
cleanup: UseEffectCleanup,
}
@@ -108,14 +108,14 @@ type UseEffectCleanup = Rc<RefCell<Option<Box<dyn FnOnce()>>>>;
/// Something that can be returned from a `use_effect` hook.
pub trait UseEffectReturn<T> {
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> TaskId;
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> Task;
}
impl<T> UseEffectReturn<()> for T
where
T: Future<Output = ()> + 'static,
{
fn apply(self, _: UseEffectCleanup, cx: &ScopeState) -> TaskId {
fn apply(self, _: UseEffectCleanup, cx: &ScopeState) -> Task {
cx.push_future(self)
}
}
@@ -127,7 +127,7 @@ where
T: Future<Output = F> + 'static,
F: FnOnce() + 'static,
{
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> TaskId {
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> Task {
cx.push_future(async move {
let cleanup = self.await;
*oncleanup.borrow_mut() = Some(Box::new(cleanup) as Box<dyn FnOnce()>);
+3 -3
View File
@@ -1,5 +1,5 @@
#![allow(missing_docs)]
use dioxus_core::{ScopeState, TaskId};
use dioxus_core::{ScopeState, Task};
use std::{any::Any, cell::Cell, future::Future, rc::Rc, sync::Arc};
use crate::{use_state, UseState};
@@ -74,7 +74,7 @@ pub enum FutureState<'a, T> {
pub struct UseFuture<T: 'static> {
update: Arc<dyn Fn()>,
needs_regen: Rc<Cell<bool>>,
task: Rc<Cell<Option<TaskId>>>,
task: Rc<Cell<Option<Task>>>,
state: UseState<Option<T>>,
}
@@ -114,7 +114,7 @@ impl<T> UseFuture<T> {
}
/// Get the ID of the future in Dioxus' internal scheduler
pub fn task(&self) -> Option<TaskId> {
pub fn task(&self) -> Option<Task> {
self.task.get()
}