Chapter 5. Build the Model
This chapter covers
- Defining the Model and how it fits into our architecture
- The relationship between the Model, Data, and Fake modules
- Setting up files for the Model
- Enabling touch devices
- Designing the people object
- Building the people object and testing the API
- Updating the Shell so users may sign in and sign out
This chapter builds on code we’ve written in chapters 3 and 4 of this book. Before starting, you should have the project files from chapter 4, as we’ll be adding to them. We recommend you copy the entire directory structure you created in chapter 4 into a new “chapter_5” directory and update it there.
In this chapter we design and build the people object portion of the Model. The Model provides the business logic and data to the Shell and feature modules. The Model is independent of the user interface (UI) and isolates it from logic and data management. The Model is itself isolated from the web server through the use of a Data module.
We want our SPA to use the people object to manage a list of people, which includes the user as well as people with whom they’re chatting. After we modify and test the Model, we update the Shell so that a user may sign in and sign out. Along the way, we add touch controls so we can use our SPA on a smart phone or tablet. Let’s get started by getting a better understanding of what the Model does and how it fits into our architecture.