Improving the render method in TodoMVC
Today's exercise was to improve the render method in TodoMVC. The problem with the render method was that it did more than just render the view. It also stored data to local storage. Here's a look at the method:
We can add comments to group these lines by functionality:
So to clean up the render method, we can move the call to util.store into its own method simply named save.
Then, everywhere where we call render in the app, we can follow it with a call to save. The intention here is to make for more readable and honest code.
Here's a look at the commit that shows the difference between the old app.js file and the new one: See commit
The full code is below.