Compare commits
2 commits
dbca9a98c8
...
e528f9e684
Author | SHA1 | Date | |
---|---|---|---|
e528f9e684 | |||
a69c51921b |
4 changed files with 23 additions and 3 deletions
|
@ -305,9 +305,13 @@ pub fn TypeaheadInput(
|
|||
// Only set initialized if component is still alive
|
||||
if closures_clone.borrow().is_alive.load(Ordering::SeqCst) && !cancel_token.get() {
|
||||
// Use a try_update to safely update the signal
|
||||
let _ = try_with_owner(Owner::current().unwrap(), move || {
|
||||
if let Some(owner) = Owner::current() {
|
||||
let _ = try_with_owner(owner, move || {
|
||||
set_initialized.set(true);
|
||||
});
|
||||
} else {
|
||||
log!("[INIT] No Leptos owner when setting initialized, aborting");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ pub mod components;
|
|||
pub mod models;
|
||||
pub mod nostr;
|
||||
pub mod api;
|
||||
pub mod utils;
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
pub mod db;
|
||||
|
||||
|
|
13
src/utils/leptos_owner.rs
Normal file
13
src/utils/leptos_owner.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
/// Utility to safely execute a closure with the current Leptos owner.
|
||||
/// If the owner is disposed, logs and returns None.
|
||||
pub fn with_owner_safe<F, R>(log_context: &str, f: F) -> Option<R>
|
||||
where
|
||||
F: FnOnce() -> R,
|
||||
{
|
||||
if let Some(owner) = leptos::Owner::current() {
|
||||
leptos::try_with_owner(owner, f).ok()
|
||||
} else {
|
||||
leptos::logging::log!("[OWNER] No Leptos owner in context: {}", log_context);
|
||||
None
|
||||
}
|
||||
}
|
1
src/utils/mod.rs
Normal file
1
src/utils/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod leptos_owner;
|
Loading…
Add table
Reference in a new issue