anp / moxie

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

`RunLoop::run_on_state_changes()` shouldn't call `run_once` unless a state change occurred #215

Open anp opened 3 years ago

anp commented 3 years ago

Right now run_on_state_changes only does the right thing if the RunLoop is the top-level task. If it's being joined with another future it might be re-run unnecessarily.

One option to fix this would be to wrap the state change waker in a layer that also notifies the RunLoop that a state change did occur. Maybe by adding a "state revision" field to the runtime and incrementing that on updates? Then we could make sure the state revision has advanced past the runtime revision when calling run_once.

I'm not sure whether the run skipping should be done in RunTime or RunLoop, I'm leaning towards the latter.