Architecture question: how to handle large state needed in many places #7823
Unanswered
andreasWallner
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a bit of a general question regarding how to handle state in the application that is needed in multiple places.
To give a bit of context, I work on surfer, a digital waveform viewer using (obviously) egui (there is an online version of it, in case anyone is interested - just click on "click here to open an example...").
The problem that I'm encountering is the following:
We have a bunch of state that is needed across the application, but it inherently display-related. In my concrete case this is "which waveforms in the main dialog are selected". From my understanding of egui that information should (?) be stored in the state of the widget itself - but due to us needing it in many places (query via network, information for completing our "console", running console commands, also interacting with data caches, etc.) we placed it in our state, with some abstraction to handle moving, expanding/collapsing our tree/etc.
All of the interaction with the UI is done via a message queue, also selection changes.
This now creates a problem for me, because as a reaction to a click I'd need to first update the selection accordingly, then display the context menu, and our context menu should be responsive to what is currently selected.
...But due to the selection happening only in the next frame (it just got put into the message queue) this becomes quite a bit annoying...
As far as I understand, we could do a few things:
I somehow have the feeling that the last option might the the "proper" one - but I'm hesitant to go down that route and I would involve major changes, and involve a bunch of other problems, like inconsistent frames when I handle the click on a label after a bunch are already rendered... (also harder testing, etc.)
And thoughts/hints/ideas on this matter?
Beta Was this translation helpful? Give feedback.
All reactions