Fix effects triggered from async tasks; improve work scheduling docs (#2370)
* outline work scheduling * move scheduling code from dirty_scope to scheduler * introduce queue_effect * Run effects after all tasks are polled if there are no components rerendered * add a new test for async effects
This commit is contained in:
1 parent
05eaca320f
commit
5290b658fd
11 files changed
+305
-53
No files matched your search
@@ -90,6 +90,11 @@ pub fn spawn(fut: impl Future<Output = ()> + 'static) -> Task {
|
||||
Runtime::with_current_scope(|cx| cx.spawn(fut)).expect("to be in a dioxus runtime")
|
||||
}
|
||||
|
||||
/// Queue an effect to run after the next render
|
||||
pub fn queue_effect(f: impl FnOnce() + 'static) {
|
||||
Runtime::with_current_scope(|cx| cx.queue_effect(f)).expect("to be in a dioxus runtime")
|
||||
}
|
||||
|
||||
/// Spawn a future that Dioxus won't clean up when this component is unmounted
|
||||
///
|
||||
/// This is good for tasks that need to be run after the component has been dropped.
|
||||
|
||||
Reference in new issue
Block a user