4.2.5 • Published 6 years ago

cf-util-route-handler v4.2.5

Weekly downloads
85
License
BSD-3-Clause
Repository
-
Last release
6 years ago

cf-util-route-handler

Cloudflare Route Handler Util

Installation

$ npm install cf-util-route-handler

Usage

import {handleRoutes, routeTo} from 'cf-util-route-handler';
import Backbone from 'backbone';

// setup the router
handleRoutes(function(url) {
  Backbone.history.navigate(url, true);
});

// do all the world to make the router work normally
new Backbone.Router({
  routes: {
    ''    : () => console.log('/'),
    hello : () => console.log('/hello'),
    world : () => console.log('/world')
  }
});
Backbone.history.start();

// start routing
routeTo('/');
routeTo('/hello');
routeTo('/world');

A handler looks like this:

handleRoutes(url => {
  takeActionWithUrl(url);
});

Only one handler is allowed to be setup.

routeTo is fire and forget, there's no callback for async transitions, and it does not return anything.

4.2.5

6 years ago

4.2.4

6 years ago

4.2.3

7 years ago

4.2.2

7 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.0

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.0

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago