The entry point
app/app.js is where the app starts. It creates one PuzzleApp with a config object and calls app.mount():
targetis the element the app renders into: the#appdiv inpublic/index.html.routesis the table fromroutes.js.formattersregisters your own display functions. The scaffold addsshout, and Home calls it as{ shout('hello') }.
Later chapters add models to this config. One more key is a hook: beforeMount(app) runs once, after the app is built and before the first page renders. It is where an app seeds its store or restores a session.
Your turn
- Add a
beforeMount(app)method to the config object. - Inside it,
console.log('Music is starting'). - Watch the console under the preview.
The file ends with export default app. The static build in the next lesson imports the app from there, so keep that line.