Skip to content

Commit

Permalink
default args that the thing can actually parse
Browse files Browse the repository at this point in the history
  • Loading branch information
jfyles committed Jan 26, 2018
1 parent 96b8ede commit 3f4091c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export class Router {
* @param {object} config - Additional configuration parameters.
* Currently only supports the interceptLinks property.
*/
constructor(store, config = {}) {
constructor(store, config) {
// Optional arguments in old-school JS since our docs generator chokes on them.
if (!config) {
config = {};
}

// Keep bound reference to dispatch so we can dispatch actions in route handlers
this.dispatch = store.dispatch.bind(store);

Expand Down Expand Up @@ -81,7 +86,12 @@ export class Router {
* @param {string} path - The path to which to navigate.
* @param {object} handler - (Optional) An additional handler to run after the standard handler.
*/
navigate(path, handler = () => {}) {
navigate(path, handler) {
// Optional arguments in old-school JS since our docs generator chokes on them.
if (!handler) {
handler = () => {};
}

const oldOnMatch = this.onMatch;
this.onMatch = handler;
crossroads.parse(path);
Expand Down

0 comments on commit 3f4091c

Please sign in to comment.