Return to just TaskId, still polling

This commit is contained in:
Exotik850 committed 2023-12-12 13:02:35 -06:00
1 parent 69ca1fd8a7
commit fdce7bbe5a
8 files changed
+26 -34

No files matched your search

+3 -3
View File
@@ -63,15 +63,15 @@ use std::future::Future;
/// }
/// })
/// ```
pub fn use_coroutine<M, G, F>(cx: &ScopeState, init: G) -> Option<&Coroutine<M>>
pub fn use_coroutine<M, G, F>(cx: &ScopeState, init: G) -> &Coroutine<M>
where
M: 'static,
G: FnOnce(UnboundedReceiver<M>) -> F,
F: Future<Output = ()> + 'static,
{
let (tx, rx) = futures_channel::mpsc::unbounded();
let task = cx.push_future(init(rx))?;
Some(cx.use_hook(|| cx.provide_context(Coroutine { tx, task })))
let task = cx.push_future(init(rx));
cx.use_hook(|| cx.provide_context(Coroutine { tx, task }))
}
/// Get a handle to a coroutine higher in the tree