barbarianmeetscoding

hackerz edition

What Is New in Knockout.js 3.0 Lightning Round

| Comments

I have been writing so much about Knockout.js lately that I thought it would be a disservice not to write about the release of its latest version, Knockout.js 3.0. I will write a lightning version, a fast and brief summary if you will, as better in-depth blog posts have already been written (see links below :) ). Without further ado, this is what is new in Knockout.js 3.0:

  1. Multiple bindings that affect the same element are evaluated independently, that is, changes in an observable no longer trigger updates in bindings that do not directly depend on it.
  2. Ordered bindings. The execution of some bindings is now done in a particular order to avoid WTF bugs. For instance, the binding value: selectedValue, options: choices would not work in Knockout 2.3, and debugging it would be a pain. This feature works for all built-in bindings and can be defined for custom bindings.
  3. You can now add an arbitrary pre-processing function to built-in and custom bindings. This function will be given the unadultered binding value before it is evaluated.
  4. Likewise, you can now add a node pre-processing function to the binding provider that will be executed for each node within the document before it is processed for bindings. (This is used in knockout punches to add support for handlerbars syntax).
  5. Knockout now supports dynamic binding handlers. You can override the new ko.getBindingHandler function that determines which binding handler to use and add bindings on the fly.
  6. New checkedValue binding that extends the functionality in the checked binding to support objects (the latter did only support the input’s value property, that is a primitive)
  7. An experimental version of observable view models, that is, switch the entire view model and update each individual binding separatel.
  8. The options binding now generates a change event, if changed (as when we remove the selected item), it will trigger updates in other bindings such as value or selectedOption.
  9. New arrayChange event that makes it super easy to figure out has an observable array has changed.
  10. Support for binding to detached nodes
  11. Support for arrays of observables in addition to observable arrays.
  12. The optionsCaption binding is now HTML encoded.
  13. Is fully (very) backward compatible

In summary, new and awesome extensibility points, performance improvements and minor yet nice bug fixes and usability improvements.

Note that much better blog posts by most experienced people have been written about this new version, so, if you have some more time to spare, please check Steven Sanderson’s Knockout.js 3.0 RC and Knockout.js 3.0 Beta blog posts and Ryan P. Niemeyer’s blog for more in-depth information and a very good screencast.

Comments