freeman-lab / control-panel

embeddable panel of inputs for parameter setting
MIT License
237 stars 17 forks source link

Echo initialized values into state object #5

Closed rreusser closed 8 years ago

rreusser commented 8 years ago

If initial is not set for an input, the state vector shows undefined even though the UI makes a selection (whether that's halfway through the range, the color #123456, or a blank string). The result is an inconsistent UI vs. state. Of course it's correct once the input is perturbed, but it remains incorrect if a different input is perturbed.

This PR adds an internal 'initialized' event that each component calls (asynchronously, seems it needs to be) so that the initialized value is read and inserted into the state object as soon as the control panel is initialized. This does not trigger an 'input' event. Let me know if this makes sense! Thanks!