Skip to content

Commit

Permalink
fix: Resource::with() pt. 2 — (closes #1742 without reopening #1711) (
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored Sep 18, 2023
1 parent 7d3e2a4 commit 2b59ae1
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 2b59ae1

Please sign in to comment.