Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Won't your example trigger an infinite loop of celsius/fahrenheit conversions? Especially if the floating point value is slightly off.

I think your example is exactly why stuff like React won vs data-binding frameworks. With declarative programming, you just have a single source of truth that you change once (you can arbitrarily pick celsius or fahrenheit or even kelvin) and let the framework figure out what needs to be diff-ed in the derived views.



I'm not aware of any actual real-world GUI system where ".whenChanged do" is valid syntax, but just for the sake of argument, pretend that it only fires when the user changes the textbox. Coincidentally, this also happens to be how the "change" event works in JavaScript.


I know of one that's essentially like that [0], but like you suggested - it only fires on user action, not programmatic update.

(The examples here are for buttons and sliders, but it's the same syntax for input fields)

[0] http://rebol.com/docs/easy-vid.html#section-20


When working on GUIs that used callbacks like this, I’d have a method for setting the value of the second component which didn’t raise a ’changed’ event, or I’d turn off raising events for the second component before telling it to change then tell it to continue.

They weren’t beautiful, but both methods worked fine for the rare cases they proved necessary.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: