Skip to content

Conversation

wvpm
Copy link
Contributor

@wvpm wvpm commented Jul 27, 2025

Replaced by #523

Depends on:

Context from Discord:
General WVPM — 25/07/2025 16:33
When it comes to reactivity in the UI I'd love to use a reactive pull based model.
Where the reactive part is event-driven marking data as dirty.
The pull part would be the UI updating all elements marked dirty.
This would be kinda like Svelte, but Svelte does it compile-time.

Sadly according to Gemini and my own research neither godot nor C++ have something like this.
We're stuck with signals and manually invalidating or directly updating UI elements.
Also we have to ensure that signals can't flood the UI with updates.

This is a error-prone approach.
I'd love to hear your thoughts on the subject. (I'll read them pull based.)

General WVPM — 09:57
I thought about it some more and came up with the following high-level idea:
Split state up into:

  • constant state
  • mutable state (properties with events)
  • derived state (tracks dependencies is marked dirty when they update. recalculates if dirty when requested)
  • manually tracked derived state

We can use signal for the events.
signal_property would have to be replaced with mutable state that exposes a get() method and changed signal.
Manually tracked derived state would be pop distributions and other aggregates that we know when to update in the sim.
You don't want to track every pop his size in the province + the list of all pops. You could just manually update that like we do now.
Mutable, derived & manually tracked derived state all implement the same interface of a get() method and changed signal.
The derived state (mainly for UI purposes) should automatically handle tracking.

@wvpm wvpm force-pushed the automatic_dependency_tracking branch 19 times, most recently from 3ed9f13 to bb268c3 Compare July 28, 2025 21:50
@Spartan322 Spartan322 added enhancement New feature or request topic:core labels Jul 28, 2025
@wvpm wvpm force-pushed the automatic_dependency_tracking branch 9 times, most recently from f7b1bdc to 7d13da1 Compare July 29, 2025 10:44
@wvpm wvpm force-pushed the automatic_dependency_tracking branch from 7d13da1 to ae0842e Compare July 29, 2025 11:57
@wvpm wvpm force-pushed the automatic_dependency_tracking branch from ae0842e to 940d1d9 Compare July 29, 2025 21:07
@wvpm wvpm added this to the 0.9.0 milestone Aug 3, 2025
@wvpm wvpm closed this Aug 4, 2025
@wvpm wvpm deleted the automatic_dependency_tracking branch August 4, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants