Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

Table of Contents (16 chapters)
Mastering KnockoutJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The data binding pattern


This section is primarily philosophical. If you feel like you already have a solid understanding of the what and why behind the Model-View-ViewModel (MVVM) pattern and binding handlers, then you might want to skip to the next section, Components of a binding handler.

Okay, let's talk about patterns and practices. If you haven't worked with WPF before, then the MVVM pattern is probably the most confusing thing about Knockout. MVVM is a pattern that came out of Microsoft. It doesn't get a lot of attention outside the .NET community, and it's similar enough to the far more popular MVC pattern because of which confusion is nearly guaranteed.

In MVVM, the viewmodel is supposed to represent an abstraction of the view. Consider these two lists of message threads in iOS:

They both show a list of threads, and each thread contains a title showing the person it is with, an excerpt from the most recent message, and a timestamp. A thread can be selected or deleted. To select a message...