bacon-routes
Route management, the bacon.js way.
Intro
Bacon.js is a library for functional reactive programming, you can get more information about it on the github project webpage.
The idea here is to handle history states and manage client-side routing using Bacon.js.
Install
You can install bacon-routes with bower or npm (in order to use it with browserify)
Using bower:
bower install --save bacon-routes
Using browserify, you currently have to put Bacon
in the global scope:
npm install --save bacon-routes
/* In your javascript file */var Bacon = windowBacon = ;;
API
Bacon.history
is a reactive property handling history changes.
Example:
Baconhistory; /* Prints: { "state": [history forwarded from popstate], "location": [window.location] }*/
Bacon.history
provides a pushState
method in order to trigger the load of a URL. See the related MDN article for further documentation.
Baconhistory;
Bacon.fromRoutes
is a method creating streams for each given route.
Example:
var routes = Bacon; /* Log history */routesusers; /* Log user id */routesuser;
By default, no event is sent until the next url change. To send an event at start, use a ready
property:
var ready = ;var routes = Bacon; /* Log history */routesusers; /* Log user id */routesuser; ready;