Knockout.js - Part 1

  • Jacob Swanner
  • 8360 views

Comments

Ivan said

Thanks for the first steps :)

SoftEngJason said

Great introductory video Jacob!! Keep up the good work!!

Ben Davies said

Thanks, good introduction.

Faculty

jacob said

@sulav, the advantages, hopefully, become apparent as the complexity of the application grows. If you were to just use jQuery, you'd end up with a long list of event listeners & handlers; and your application logic ends up getting spread across all the event handlers, making it harder to reason about what your application will do.

Let's give an example: at 16:22 in the video, when I clicked on the reset button, it set the count value to 0, but that also caused the reset button to go away. If you were to do this using jQuery: the event handler for the reset button would need to set the count to 0 and also hide itself, and the event handler for the increment button would need to check each time it is clicked if the reset button can be shown. So, this is a simple example, but you can see that the logic to hide/show the reset button is spread across two event handlers. Whereas, with the knockout example, I never modified the value of allowReset directly, it was defined in terms of count -- which is the only thing I ever modified.

Sulav said

Jacob, what's the advantage of using Knockout to do this over using plain javascript / jQuery?

Faculty

jacob said

@porsche, I've actually changed much of my vim setup since making that screencast. Here's my current vim configuration: https://github.com/jswanner/dotvim

In the screencast, the font I was using was DejaVu Sans Mono, desert color scheme (which ships with vim), and I think the only plugin I used in the screencast was surround.vim

Pochara Prapatanant said

Can you share your vim config and plugins? Your vim looks great. Awesome cast. Thanks!

netoben said

Very nice video. I didn't know of knockout and it looks great.!