wip: rip out unsafe task engine

This commit is contained in:
Jonathan Kelley committed 2021-12-26 14:22:30 -05:00
1 parent cda759c659
commit c7d001cbb4
10 files changed
+144 -136

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
use dioxus_core::{ScopeState, TaskId};
use std::{cell::Cell, future::Future};
pub fn use_future<'a, T: 'static, F: Future<Output = T>>(
cx: &'a ScopeState,
f: impl FnOnce() -> F,
) -> FutureHandle<'a, T> {
cx.use_hook(
|_| {
//
UseFutureInner {
needs_regen: true,
task: None,
}
},
|_| {
//
FutureHandle {
cx,
value: Cell::new(None),
}
},
)
}
struct UseFutureInner {
needs_regen: bool,
task: Option<TaskId>,
}
pub struct FutureHandle<'a, T> {
cx: &'a ScopeState,
value: Cell<Option<T>>,
}