Skip to content

Commit

Permalink
fix: allow multiple overlapping notifications of AsyncDerived/LocalRe…
Browse files Browse the repository at this point in the history
…source (closes leptos-rs#3454) (leptos-rs#3455)
  • Loading branch information
gbj authored Jan 7, 2025
1 parent 5751863 commit 165911b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions reactive_graph/src/computed/async_derived/arc_async_derived.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ impl<T: 'static> ArcAsyncDerived<T> {
) {
loading.store(false, Ordering::Relaxed);

inner.write().or_poisoned().state = AsyncDerivedState::Notifying;
let prev_state = mem::replace(
&mut inner.write().or_poisoned().state,
AsyncDerivedState::Notifying,
);

if let Some(ready_tx) = ready_tx {
// if it's an Err, that just means the Receiver was dropped
Expand All @@ -433,7 +436,10 @@ impl<T: 'static> ArcAsyncDerived<T> {
waker.wake();
}

inner.write().or_poisoned().state = AsyncDerivedState::Clean;
// if this was marked dirty before notifications began, this means it
// had been notified while loading; marking it clean will cause it not to
// run on the next tick of the async loop, so here it should be left dirty
inner.write().or_poisoned().state = prev_state;
}
}

Expand Down

0 comments on commit 165911b

Please sign in to comment.