The entry point

app/app.js is where the app starts. It creates one PuzzleApp with a config object and calls app.mount():

  • target is the element the app renders into: the #app div in public/index.html.
  • routes is the table from routes.js.
  • formatters registers your own display functions. The scaffold adds shout, 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

  1. Add a beforeMount(app) method to the config object.
  2. Inside it, console.log('Music is starting').
  3. 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.

Chapters