0.3.3 • Published 5 years ago

@cubex/router v0.3.3

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

Cubex Router

Build Status npm version

import Router from '@cubex/router';

class Application {
    router: Router = new Router();

    constructor() {
        /*
         * Sets Default Route
         */
        this.router.setDefaultRoute(function () {
            console.log('Route: Default');
        });

        /*
         * Set Error Route
         */
        this.router.setErrorRoute(function () {
            console.log('Route: Default');
        });

        /*
         * Set Route and exit function
         */
        this.router.addRegex('test', function () {
            console.log('Route: Test');
        }, function(newHash: string) {
            console.log('Route Exit: Test, New Hash: ' + newHash);
        });

        /*
         * Set Route with parameter
         */
        this.router.addRegex('test/:id', function (id) {
            console.log('Route: Test, id: ' + id);
        });

        /*
         * Set Route with two parameters defined by function
         */
        this.router.addFunction('test', function (id, name) {
            console.log('Route: Test, id: ' + id + ', name: ' + name);
        });
    }

    /*
     * Start Router, with option to defer run until route change
     */
    start(defer: boolean = false) {
        this.router.start(defer);
    }

    /*
     * Stop Router
     */
    stop() {
        this.router.stop();
    }
}
0.3.3

5 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago