diff --git a/Cargo.toml b/Cargo.toml
index 4cd6e311c..dcd62426f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,14 +20,14 @@ dioxus-ssr = { path = "./packages/ssr", optional = true }
[features]
default = [
"core",
- "atoms",
"macro",
- "ssr",
"hooks",
- "router",
"html",
- "web",
- "desktop",
+ # "atoms",
+ # "ssr",
+ # "router",
+ # "web",
+ # "desktop",
]
atoms = []
macro = ["dioxus-core-macro"]
@@ -43,17 +43,17 @@ core = []
[dev-dependencies]
-futures = "0.3.15"
-log = "0.4.14"
-num-format = "0.4.0"
-separator = "0.4.1"
-serde = { version = "1.0.126", features = ["derive"] }
-surf = "2.2.0"
-env_logger = "*"
-async-std = { version = "1.9.0", features = ["attributes"] }
-im-rc = "15.0.0"
-rand = { version = "0.8.4", features = ["small_rng"] }
-fxhash = "0.2.1"
+# futures = "0.3.15"
+# log = "0.4.14"
+# num-format = "0.4.0"
+# separator = "0.4.1"
+# serde = { version = "1.0.126", features = ["derive"] }
+# surf = "2.2.0"
+# env_logger = "*"
+# async-std = { version = "1.9.0", features = ["attributes"] }
+# im-rc = "15.0.0"
+# rand = { version = "0.8.4", features = ["small_rng"] }
+# fxhash = "0.2.1"
[workspace]
@@ -62,9 +62,9 @@ members = [
"packages/core-macro",
"packages/html",
"packages/hooks",
- "packages/web",
- "packages/webview",
- "packages/ssr",
+ # "packages/web",
+ # "packages/webview",
+ # "packages/ssr",
# "packages/atoms",
# "packages/docsite",
]
diff --git a/packages/core/examples/async.rs b/packages/core/examples/async.rs
index a6a0749a7..ad67be67a 100644
--- a/packages/core/examples/async.rs
+++ b/packages/core/examples/async.rs
@@ -22,3 +22,15 @@ const App: FC<()> = |cx| {
todo!()
};
+
+const Task: FC<()> = |cx| {
+ //
+
+ let s = cx.use_task(|| async { "hello world".to_string() });
+
+ todo!()
+};
+
+fn use_mut
(cx: Context
, f: impl FnOnce() -> T) -> &mut T {
+ todo!()
+}
diff --git a/packages/core/src/context.rs b/packages/core/src/context.rs
index 01b9aaef7..b38b83b8e 100644
--- a/packages/core/src/context.rs
+++ b/packages/core/src/context.rs
@@ -2,9 +2,12 @@ use crate::hooklist::HookList;
use crate::{arena::SharedArena, innerlude::*};
use appendlist::AppendList;
use bumpalo::Bump;
+use futures_util::{pin_mut, FutureExt};
use slotmap::DefaultKey;
use slotmap::SlotMap;
+use std::borrow::BorrowMut;
use std::marker::PhantomData;
+use std::sync::{Arc, RwLock};
use std::{
any::{Any, TypeId},
cell::{Cell, RefCell},
@@ -39,9 +42,9 @@ use std::{
pub struct Context<'src, T> {
pub props: &'src T,
pub scope: &'src Scope,
- pub tasks: &'src RefCell>,
+ pub tasks: &'src RefCell>>,
}
-pub type PinnedTask = Pin>>;
+// pub type PinnedTask = Pin>>;
impl<'src, T> Copy for Context<'src, T> {}
impl<'src, T> Clone for Context<'src, T> {
@@ -263,18 +266,6 @@ Any function prefixed with "use" should not be called conditionally.
)
}
- pub fn suspend VNode<'src> + 'src>(
- &'src self,
- fut: &'src mut Pin + 'static>>,
- callback: Fut,
- ) -> VNode<'src> {
- use futures_util::FutureExt;
- match fut.now_or_never() {
- Some(out) => callback(SuspendedContext {}, out),
- None => NodeFactory::suspended(),
- }
- }
-
/// `submit_task` will submit the future to be polled.
///
/// This is useful when you have some async task that needs to be progressed.
@@ -289,11 +280,96 @@ Any function prefixed with "use" should not be called conditionally.
///
///
///
- pub fn submit_task(&self, task: &'src mut PinnedTask) -> TaskHandle {
- self.tasks.borrow_mut().push(task);
+ pub fn submit_task(&self, task: Pin>>) -> TaskHandle {
+ // let r = task.then(|f| async {
+ // //
+ // });
+ // self.use_hook(|| Box::new(r), |_| {}, |_| {});
+ // *task = task.then(|f| async {
+ // //
+ // t
+ // // ()
+ // });
+ todo!();
+ // let new_fut = task.then(|f| async {
+ // //
+ // ()
+ // });
+ // self.tasks.borrow_mut().push(new_fut);
TaskHandle { _p: PhantomData {} }
}
+
+ /// Awaits the given task, forcing the component to re-render when the value is ready.
+ ///
+ ///
+ pub fn use_task(
+ &self,
+ task_initializer: impl FnOnce() -> Fut + 'src,
+ ) -> &mut Option
+ where
+ Out: 'static,
+ Fut: Future