Skip to content

Instantly share code, notes, and snippets.

@dearshrewdwit
Last active December 11, 2018 17:39
Show Gist options
  • Select an option

  • Save dearshrewdwit/01fe9b48a1a0c1655b40bb093deb3d0a to your computer and use it in GitHub Desktop.

Select an option

Save dearshrewdwit/01fe9b48a1a0c1655b40bb093deb3d0a to your computer and use it in GitHub Desktop.
SPA guidance

Frontend, single page app guidance

  • How will you write and run unit tests? Have a look at πŸ’Š writing tests without a testing library.

  • How will you intercept form submissions so they don't reload the page? form submit event and preventDefault may prove useful.

  • How will you implement the domain model? Maybe the constructor and prototype pattern?

  • How will you construct your HTML content? You could write a view module. Maybe it will concatenate strings? Maybe it will use a tiny tiny templating framework that you write.

  • How will you intercept URL changes so that they don't reload the page? Have a look at πŸ’Š frontend, single page app.

  • How will you map URLs to resources? How will you render HTML to the page? How will you let your HTML interface interact with your models in a clean way? Maybe a controller or two?

Further

  • How will you make requests to external APIs? Maybe Ajax with raw XMLHttpRequest objects?

  • How will you serve your app? Maybe a very simple node library like πŸ’Š http-server? (This is exempt from the "no frameworks, no libraries" rule.)

  • Maybe you won't write any feature tests. If you do, how will you do it? Maybe you could write tests as functions that use DOM methods like click to click on things, and include your test file into your index.html when you want to run your tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment