Creating an Observable

Imagine that I have created a product object like this:

var product = {    name: "Milk",    description: "Something to drink",    price: 12.33};

There’s nothing very exciting about this product. It has three properties named name, description, and price.

Now, imagine that I want to be notified automatically whenever any of these properties are changed. In that case, I can create an observable product from my product object like this:

var observableProduct = WinJS.Binding.as(product);

This line of code creates a new JavaScript object named observableProduct from the existing JavaScript object named product. This new object also has a name, description, and price ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.