Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lambdabaa/simplerouter

Yet another client-side js router!
https://github.com/lambdabaa/simplerouter

Last synced: 7 days ago
JSON representation

Yet another client-side js router!

Awesome Lists containing this project

README

        

simplerouter
============

Yet another client-side js router!

### Usage

```js

var router = new Router({
anchorElement: document.getElementById('anchor'),
defaultState: { color: 'green' }
});

router.route = state => state.color;

/**
* @return {Promise} promise that accepts with created view.
*/
router.initView = viewName => {
var element = document.createElement('div');
// ... initialize element
return element;
};

router.start().then(() => {
router.setState({ color: 'yellow' }); // Go to yellow page.
});

```