* clear away prelude on dioxus * clippy * wip - drop prelude from dioxus-html * docs clippy * wip * more fixe * delete all preludes * doc... * better export * merge some imports * fewer global imports * global incremental renderer * fix cargo doc
21 lines
837 B
Rust
21 lines
837 B
Rust
use dioxus_core::{suspense_context, use_hook};
|
|
|
|
/// Run a closure after the suspense boundary this is under is resolved. The
|
|
/// closure will be run immediately if the suspense boundary is already resolved
|
|
/// or the scope is not under a suspense boundary.
|
|
pub fn use_after_suspense_resolved(suspense_resolved: impl FnOnce() + 'static) {
|
|
use_hook(|| {
|
|
// If this is under a suspense boundary, we need to check if it is resolved
|
|
match suspense_context() {
|
|
Some(context) => {
|
|
// If it is suspended, run the closure after the suspense is resolved
|
|
context.after_suspense_resolved(suspense_resolved)
|
|
}
|
|
None => {
|
|
// Otherwise, just run the resolved closure immediately
|
|
suspense_resolved();
|
|
}
|
|
}
|
|
})
|
|
}
|