Client-side program architecture
The basic idea is simple: the user searches for the name of someone on GitHub in the input box. When he enters a name, we fire a request to the API designed earlier in this chapter. When the response from the API returns, the program binds that response to a model and emits an event notifying that the model has been changed. The views listen for this event and refresh from the model in response.
Designing the model
Let's start by defining the client-side model. The model holds information regarding the repos of the user currently displayed. It gets filled in after the first search.
// public/javascripts/model.js define([], function(){ return { ghubUser: "", // last name that was searched for exists: true, // does that person exist on github? repos: [] // list of repos } ; });
To see a populated value of the model, head to the complete application example on app.scala4datascience.com
, open a JavaScript console in your browser...