Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resource::with() pt. 2 — (closes #1742 without reopening #1711) #1750

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions leptos_reactive/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ where
.ok()?
.flatten();

self.handle_result(location, global_suspense_cx, suspense_cx, v)
self.handle_result(location, global_suspense_cx, suspense_cx, v, false)
}

#[track_caller]
Expand All @@ -1152,6 +1152,7 @@ where
global_suspense_cx,
suspense_cx,
was_loaded.then_some(v),
true,
)
} else {
Some(v)
Expand All @@ -1164,6 +1165,7 @@ where
global_suspense_cx: Option<GlobalSuspenseContext>,
suspense_cx: Option<SuspenseContext>,
v: Option<U>,
force_suspend: bool,
) -> Option<U> {
let suspense_contexts = self.suspense_contexts.clone();
let has_value = v.is_some();
Expand Down Expand Up @@ -1223,7 +1225,7 @@ where
// on subsequent reads, increment will be triggered in load()
// because the context has been tracked here
// on the first read, resource is already loading without having incremented
if !has_value {
if !has_value || force_suspend {
s.increment(
serializable != ResourceSerialization::Local,
);
Expand All @@ -1242,7 +1244,7 @@ where
if !contexts.contains(s) {
contexts.insert(*s);

if !has_value {
if !has_value || force_suspend {
s.increment(
serializable
!= ResourceSerialization::Local,
Expand Down