bodil / vgtk

A declarative desktop UI framework for Rust built on GTK and Gtk-rs
http://bodil.lol/vgtk/
Other
1.05k stars 37 forks source link

Is there a way to preserve component's state when props change? #72

Open ostronom opened 3 years ago

ostronom commented 3 years ago

Suppose we are writing some kind of Login form and we have a component, that listens to on changed on a couple of Entry's which emit events with text upon which the component decides to enable/disable Login button. All user inputs from those entires are captured in Model as user types (to calculate validations and to emit the complete "form" via callback).

The next thing is that we want also to disable the login button right after user clicks it to prevent mulitclicking. To do so we provide an busy prop that is set on component in the outer UI declaration.

Right now if we change this busy param from outside the component -- the component will lose it's state (e.g. all of user inputs will still be in their respective UI widgets, but the model will be Default-ed) which leads to inconsistent disable/enable behavior.

Here is an example of this behavior.

pepijndevos commented 3 years ago

I'm not sure I understand what you mean by the model being defautled by setting the busy param from the outside