mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 09:54:41 -05:00
fix: ensure that arena is reestablished for cleanups
This commit is contained in:
@@ -291,12 +291,18 @@ impl Owner {
|
||||
/// fill the same need as an "on unmount" function in other UI approaches, etc.
|
||||
pub fn on_cleanup(fun: impl FnOnce() + Send + Sync + 'static) {
|
||||
if let Some(owner) = Owner::current() {
|
||||
owner
|
||||
.inner
|
||||
.write()
|
||||
.or_poisoned()
|
||||
.cleanups
|
||||
.push(Box::new(fun));
|
||||
let mut inner = owner.inner.write().or_poisoned();
|
||||
|
||||
#[cfg(feature = "sandboxed-arenas")]
|
||||
let fun = {
|
||||
let arena = Arc::clone(&inner.arena);
|
||||
move || {
|
||||
Arena::set(&arena);
|
||||
fun()
|
||||
}
|
||||
};
|
||||
|
||||
inner.cleanups.push(Box::new(fun));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user