Hacker News new | ask | show | jobs
by seanmcdirmid 4249 days ago
Well, there are many hacks around it; see the immediate-mode programming frameworks like Sol. My own personal take on this problem is to make "refresh" a first-class part of the programming model (rather than something managed by the programmer), and then to define encapsulated state that is preserved on refresh (by the programming model). You can read about it in my paper. (http://research.microsoft.com/apps/pubs/default.aspx?id=2112...)

The trick is to generate stable IDs to represent the state, then you can think of it as a global map:

    var map = new Map()
    
    def render():
      var x = map[0x138293]
      ...
      map[0x13244] = y
This resembles your last solution above. The trick is then automatically reproducing those IDs when render is called again (not to mention tearing down any side effects no longer performed, but that is another kettle of fish).