leptos = { version = "0.6.12", features = ["csr"] }
leptos_router = { version = "0.6.12"}
Expected behaviortry_with to return None for disposed resources.
Additional context
Attempted to implement resource caching as described here.
Navigating away from the page causes resources in the cache to be disposed,
after returning to the page, the cached (and now disposed) resources are unusable, with no way to test if cached resource needs to be replaced by new one.
The only user of runtime.try_resource() without unwrap is try_update, which cannot be used for testing whether resource is disposed, calling try_update breaks loading for non-disposed resources.
Describe the bug According to documentation, calling
try_with
should returnNone
if signal is no longer valid. Instead it callspanic!
.It calls
runtime.resource
: https://github.com/leptos-rs/leptos/blob/2ef27cb0bb485b7ad33e0e3d5f144718504ad757/leptos_reactive/src/resource.rs#L801 which panics: https://github.com/leptos-rs/leptos/blob/2ef27cb0bb485b7ad33e0e3d5f144718504ad757/leptos_reactive/src/runtime.rs#L1279-L1284Leptos Dependencies
Expected behavior
try_with
to returnNone
for disposed resources.Additional context Attempted to implement resource caching as described here.
Navigating away from the page causes resources in the cache to be disposed, after returning to the page, the cached (and now disposed) resources are unusable, with no way to test if cached resource needs to be replaced by new one.
The only user of
runtime.try_resource()
withoutunwrap
istry_update
, which cannot be used for testing whether resource is disposed, callingtry_update
breaks loading for non-disposed resources.