Defining steps with template functions
A template is a design pattern that details the order a given set of operations are to be executed in; however, a template does not outline the steps themselves. This pattern is useful when behavior is divided in to phases that have some conceptual or side effect dependency that requires them to be executed in a specific order.
In this recipe, we'll see how to use the template function design pattern.
Getting ready
This recipe assumes you already have a workspace that allows you to create and run ES modules in your browser. If you don't, please see the first two chapters.
How to do it...
- Open your command-line application and navigate to your workspace.
- Create a new folder named
09-01-defining-steps-with-template-functions
. - Copy or create an
index.html
file that loads and runs amain
function frommain.js
. - Create a
main.js
file that defines a new abstractclass
namedMission
:
// main.js class Mission { constructor () { if (this.constructor === Mission...