Skip to content

Commit

Permalink
feat: add setOption(opt, val) chainable method
Browse files Browse the repository at this point in the history
  • Loading branch information
troch committed Jul 3, 2015
1 parent 413cd61 commit b45b0de
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ __Options:__

### Router instance API

__router.setOption(opt, value)__

A chainable method to set a specific option.

__router.start()__

Start the router listening to _popstate_ events and allow navigation. On start, the router
Expand All @@ -123,6 +127,11 @@ __router.add(route)__

- __route__ `Array[Object|RouteNode]|RouteNode|Object` Add routes to the route tree

__router.addNode(name, path)__

- __name__ `String` the name of the route to add. You can add a nested route by specifying its full name (i.e. 'a.b.c.d').
- __path__ `String` the route path. For a full syntax overview, see [path-parser](https://github.com/path-parser).

__router.rootNode__

The top node `RouteNode` instance. For a detailled API, see [RouteNode's README](https://github.com/troch/route-node/blob/master/README.md)
Expand Down
6 changes: 6 additions & 0 deletions dist/commonjs/router5.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ var Router5 = (function () {
}

_createClass(Router5, [{
key: 'setOption',
value: function setOption(opt, val) {
this.options[opt] = val;
return this;
}
}, {
key: 'add',
value: function add(routes) {
this.rootNode.add(routes);
Expand Down
6 changes: 6 additions & 0 deletions dist/umd/router5.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
}

_createClass(Router5, [{
key: 'setOption',
value: function setOption(opt, val) {
this.options[opt] = val;
return this;
}
}, {
key: 'add',
value: function add(routes) {
this.rootNode.add(routes);
Expand Down
5 changes: 5 additions & 0 deletions modules/Router5.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export default class Router5 {
return this
}

setOption(opt, val) {
this.options[opt] = val
return this
}

add(routes) {
this.rootNode.add(routes)
return this
Expand Down
4 changes: 2 additions & 2 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ var ordersRoute = new RouteNode('orders', '/orders', [
router = new Router5([
userRoutes
], {
defaultRoute: 'home',
useHash: true
defaultRoute: 'home'
})
.setOption('useHash', true)
.add(ordersRoute)
.addNode('home', '/home');

Expand Down

0 comments on commit b45b0de

Please sign in to comment.