Skip to content

Instantly share code, notes, and snippets.

@jstrimpel
Last active September 8, 2015 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstrimpel/99d0009f677a0e196cf3 to your computer and use it in GitHub Desktop.
Save jstrimpel/99d0009f677a0e196cf3 to your computer and use it in GitHub Desktop.
code sample pattern
// this outlines the recommended approach for handling code samples in the book
// block 1 introdcues a stubbed module
// block 2 contains implementation details for subbed module method
// this prevents duplication while still providing context
// comments before code block would be the code block tile in the book
// [[app_stub_2_4]]
// Application Stub
export default class Application {
constructor(routes, options) {
}
navigate(url, push=true) {
}
start() {
}
}
// [[app_constructor_2_4]]
// <<app_stub_2_4>> constructor method
constructor() {
// save off routes as look up table for controllers
this.routes = routes;
this.options = options;
// create a call router instance
this.router = new Call.Router();
this.registerRoutes(routes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment