Return to just TaskId, still polling
This commit is contained in:
1 parent
69ca1fd8a7
commit
fdce7bbe5a
8 files changed
+26
-34
No files matched your search
@@ -99,9 +99,8 @@ where
|
||||
// Create the new future
|
||||
let return_value = future(dependencies.out());
|
||||
|
||||
if let Some(task) = return_value.apply(state.cleanup.clone(), cx) {
|
||||
state.task.set(Some(task));
|
||||
}
|
||||
let task = return_value.apply(state.cleanup.clone(), cx);
|
||||
state.task.set(Some(task));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,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) -> Option<TaskId>;
|
||||
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> TaskId;
|
||||
}
|
||||
|
||||
impl<T> UseEffectReturn<()> for T
|
||||
where
|
||||
T: Future<Output = ()> + 'static,
|
||||
{
|
||||
fn apply(self, _: UseEffectCleanup, cx: &ScopeState) -> Option<TaskId> {
|
||||
fn apply(self, _: UseEffectCleanup, cx: &ScopeState) -> TaskId {
|
||||
cx.push_future(self)
|
||||
}
|
||||
}
|
||||
@@ -128,7 +127,7 @@ where
|
||||
T: Future<Output = F> + 'static,
|
||||
F: FnOnce() + 'static,
|
||||
{
|
||||
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> Option<TaskId> {
|
||||
fn apply(self, oncleanup: UseEffectCleanup, cx: &ScopeState) -> TaskId {
|
||||
cx.push_future(async move {
|
||||
let cleanup = self.await;
|
||||
*oncleanup.borrow_mut() = Some(Box::new(cleanup) as Box<dyn FnOnce()>);
|
||||
|
||||
Reference in new issue
Block a user