dioxus/packages/core/examples/async.rs

40 lines
768 B
Rust
Raw Normal View History

use dioxus_core::prelude::*;
2021-07-13 20:52:25 +00:00
fn main() {}
2021-09-21 17:42:52 +00:00
const App: FC<()> = |cx, props| {
2021-07-09 15:54:07 +00:00
// create a new future
2021-07-13 20:52:25 +00:00
let _fut = cx.use_hook(
2021-07-15 03:18:02 +00:00
|_| {
//
2021-07-09 15:54:07 +00:00
async { loop {} }
// Box::pin(async { loop {} }) as Pin<Box<dyn Future<Output = ()>>>
},
|f| f,
|_| {},
);
2021-07-09 15:54:07 +00:00
// let g = unsafe { Pin::new_unchecked(fut) };
// cx.submit_task(fut);
2021-07-09 07:39:45 +00:00
todo!()
};
2021-07-13 20:48:11 +00:00
2021-09-21 17:42:52 +00:00
const Task: FC<()> = |cx, props| {
2021-09-01 04:57:04 +00:00
let (_task, _res) = use_task(cx, || async { true });
// task.pause();
// task.restart();
// task.stop();
// task.drop();
2021-07-13 20:48:11 +00:00
//
2021-07-27 15:28:05 +00:00
let _s = use_task(cx, || async { "hello world".to_string() });
2021-07-13 20:48:11 +00:00
todo!()
};
2021-09-21 17:42:52 +00:00
fn use_mut<P, T>(_cx: Context, _f: impl FnOnce() -> T) -> &mut T {
2021-07-13 20:48:11 +00:00
todo!()
}