anp / moxie

lightweight platform-agnostic tools for declarative UI
https://moxie.rs
Apache License 2.0
828 stars 27 forks source link

Setting the state change waker must take effect for all existing state `Var`s too #220

Open zetanumbers opened 3 years ago

zetanumbers commented 3 years ago

This needs some change in public API that would also make sense. I think we should require to specify some kind of reference to the waker for each passed function. Should help resolve issue #215.

anp commented 3 years ago

If I understand correctly from our Discord conversation, the issue you're seeing looks like:

  1. set a runtime R1's waker to W1
  2. call R1.run_once(), creating some cached values and Vars
  3. calls to Var::update wake W1
  4. call R1.set_state_change_waker(W2)
  5. calls to Var::update should wake W2 but don't

Is that correct? If so this would also be an issue even if you called R1.run_once() after step 4 but before step 5.