O'Reilly logo

Serverless Single Page Apps by Ben Rady

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Router Function

Now that we’ve got a failing test, we can write the router function. To get our router test to pass, we have to add three things. We need to create a view container in the markup to give the router a place to add the views. We need to create the showView function and have it create a minimal version of the problem view. Lastly, we need to create a namespace where our router function—and the rest of our application—can live. Once those things are complete, we’ll have the first version of our router in place. All it will be able to do is switch from one view to another, but that’s a good start.

Since our test is complaining about not being able to find the learnjs namespace, we’re going to start with that.

Creating a Namespace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required