dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Signal subscribers added during an update gets ignored

Open elias098 opened this issue 10 months ago • 0 comments

Problem

Currently new subscribers created when updating subscribers get overwritten, thus are ignored.

the code looks like this

// We cannot hold the subscribers lock while calling mark_dirty, because mark_dirty can run user code which may cause a new subscriber to be added. If we hold the lock, we will deadlock.
let mut subscribers = std::mem::take(&mut *inner.subscribers.lock().unwrap());
subscribers.retain(|reactive_context| reactive_context.mark_dirty());
*inner.subscribers.lock().unwrap() = subscribers;

but i would expect

*inner.subscribers.lock().unwrap() = subscribers;

to be something like

*inner.subscribers.lock().unwrap().extend(subscribers);

Questionnaire

  • [ ] I'm interested in fixing this myself but don't know where to start
  • [ ] I would like to fix and I have a solution
  • [ ] I don't have time to fix this right now, but maybe later

elias098 avatar Apr 13 '24 21:04 elias098