0.0.14 • Published 8 years ago

bike-lane v0.0.14

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

BikeLane

Build Status

BikeLane is a client-side router.

  • Stand-alone. Use with any other library or framework.
  • No dependencies.
  • Uses HTML5 history mode.

Installation

npm

$ npm install --save bike-lane

Router API

Router.constructor()

Create a router for your page:

var router = new Router()

BikeLane currently only supports using one router per page.

Router.addRoute(route, handler)

Add a route:

router.addRoute('/user', function() {
  console.log('User route handler called.')
})

Routes can have named parameters:

router.addRoute('/user/:id', function(data) {
  let userId = data.parameter('id')
  console.log('User ID is', userId)
})

Use a wildcard at the end to match a group of routes:

/food/* /user/:id/action/*

/food/* will match /food/pizza and /food/burger. It will not match /food.

The router will only match a single route and gives priority to routes registered first.

For example:

router.addRoute('/food/:type', handlerOne)
router.addRoute('/food/pizza', handlerTwo)

handlerTwo() will never be called as the /food/:type route was registered first.

Router.start() & Router.stop()

Router.start() activates the router will trigger the handler for the current URL.

Router.stop() stops the router.

Router.navigate(url)

Call navigate() to change location. Internally, the router will update the window location using history.pushState().

Version

Version 0.0.14: Intitial release. Don't use this in projects yet.

Versioning

BikeLane will be maintained under the Semantic Versioning guidelines. Releases will be numbered with the following format:

<major>.<minor>.<patch>

  • Incompatible API changes bump the major (and resets the minor and patch)
  • New functionality introduced in a backwards-compatible manner will bump the minor.
  • Backwards-compatible bug fixes will bump the patch.

For more information please visit http://semver.org/spec/v2.0.0.html.

License

MIT

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago