You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can Reflex deal with some state/components running in subprocesses? #3418
Suppose I have a main process that starts a subprocess. The main process is an application that visualizes the subprocess. Can the subprocess create state/components that can be added to a UI in the main process?
You currently can't dynamically add new elements to the UI. The way to do this would be to use rx.cond in the UI and have the subprocess set different state vars, which will in turn update the UI. What kind of subprocess are you thinking of running? The recommended approach for long-running tasks is to use background events.
I'm playing around with a debugger that can execute visualisation code in the browser. I found some clever workaround though. However, I am trying to create a recursive state, but it won't render. I keep getting errors with the necessary typing.ForwardRef. This would explain why... Frustrating day... Is there a plan to make dynamic UI possible?
@picklelo What do you mean by "dynamically add new elements"?
Do you mean:
A: the ui tree is entirely fixed from the start, cond just sets which branches are visible, or
B the ui can only be constructed from static elements, but these elements can be composed in many ways, as long as you use rx.cond ?
C: Other (please enlighten me (: )
If the case is B I suggest emphasizing this a little better in your (otherwise excellent) documentation
@Lendemor So it is impossible for a component to reference itself... i.e. you can not create a tree... oh dear... that is a rather big constraint that is going to make reflex unusable for what I intend to do with it in one project...
Are there any plans to make this possible in the (near) future, or do I give up on reflex for my tree based project?
Activity
picklelo commentedon Jun 3, 2024
You currently can't dynamically add new elements to the UI. The way to do this would be to use
rx.condin the UI and have the subprocess set different state vars, which will in turn update the UI. What kind of subprocess are you thinking of running? The recommended approach for long-running tasks is to use background events.guidocalvano commentedon Jun 4, 2024
I'm playing around with a debugger that can execute visualisation code in the browser. I found some clever workaround though. However, I am trying to create a recursive state, but it won't render. I keep getting errors with the necessary typing.ForwardRef. This would explain why... Frustrating day... Is there a plan to make dynamic UI possible?
guidocalvano commentedon Jun 5, 2024
@picklelo What do you mean by "dynamically add new elements"?
Do you mean:
A: the ui tree is entirely fixed from the start, cond just sets which branches are visible, or
B the ui can only be constructed from static elements, but these elements can be composed in many ways, as long as you use rx.cond ?
C: Other (please enlighten me (: )
If the case is B I suggest emphasizing this a little better in your (otherwise excellent) documentation
Lendemor commentedon Jun 5, 2024
A)The UI tree is set during compilation, withrx.cond,rx.foreach, andrx.matchallowing user to control what is visible and isn't.guidocalvano commentedon Jun 5, 2024
@Lendemor So it is impossible for a component to reference itself... i.e. you can not create a tree... oh dear... that is a rather big constraint that is going to make reflex unusable for what I intend to do with it in one project...
Are there any plans to make this possible in the (near) future, or do I give up on reflex for my tree based project?
adhami3310 commentedon Jan 7, 2025
@guidocalvano currently there's CSR and components can reference itself when #4599 merges