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

Could you give a more concrete example of the idempotent update problem, please? It's too abstract for me to follow.


Here's a fiddle:

http://jsfiddle.net/H4ADp/

The counter shows the portion of the application state you're tracking while the contents of the textarea show the part you're not. It's obviously stupid but the contents of the textbox are an easily visible way of allowing you to mutate the DOM (other mutations could be attached event listeners, instantiated jQuery UI widgets, etc) and see it undone.

I'll add that even if it seems like you can track all the state (e.g. add a textarea field to the model and set a keyup or blur to save the contents for re-render) that's a disaster. If you're typing in the middle of the textarea the cursor position isn't remembered. You can store that too but what if you resize the text field? The list of edge cases is endless. You really want to bypass it by using something that updates the DOM intelligently.


Thanks, that example makes the issue very clear.




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

Search: