6. The model layer: an overview

Let’s examine the model layer in more detail. In the introduction chapter, a model was shown as something that simply queries and writes to storage. The diagram below shows more details of the model layer:

The model layer looks fairly similar across different single page app frameworks; there just aren’t that many different ways to solve this problem. You need to ability to represent data items and sets of data items; you need a way to load in data; and you probably want to have some caching in place to avoid naively reloading data that you already have. Whether these exist as separate mechanisms, or as a part of single large model is mostly a implementation detail.

The major difference is how collections are handled, and this is a result of choices made in the view layer - with observables, you want observable arrays, with events, you want collections.