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

so do you stringify all your state?


Yes, but not in the sense of dumping serialized JSON into HTML. It ends up being represented by custom HTML attributes and their values. For example, if you need to keep track if the user clicked on some button, you might represent it as follows:

  <button i-was-clicked="false">
or

  <button i-count-clicks>
The content of the attribute becomes "1" after the first click and keeps increasing. The job of the corresponding JS code would be purely to keep track of clicks, so it would be very simple. Meanwhile, the value could be used for a variety of different tasks (including in CSS) and the exact same library could be applied to any element without any modification or writing "glue code".




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

Search: