February 2015
Intermediate to advanced
232 pages
4h 40m
English
The last example shows us how Knockout binds data and the user interface, but it doesn't show the magic of the automatic UI refresh. To perform this task, Knockout uses observables.
Observables are the main concept of Knockout. These are special JavaScript objects that can notify subscribers about changes, and can automatically detect dependencies. For compatibility, ko.observable objects are actually functions.
To read an observable's current value, just call the observable with no parameters. In this example, product.price() will return the price of the product, and product.name() will return the name of the product.
var product = Product(1,"T-Shirt", 10.00, 20); product.price();//returns 10.00 product.name();//returns ...
Read now
Unlock full access