1.0.15 • Published 5 years ago

mvcr v1.0.15

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

mvcr

Zero-Dependency Client-Side Javascript Router

Description

This is a simple hash-based router that does path matching off of provided regular expressions.

Install

npm install mvcr

Usage

    import Router from 'mvcr'

    const router = new Router({
        routes: {
            default: {
                re: /(.*)/,
                handler: function (ctx) {
                    console.log(ctx)
                }
            }
        }
    })

    router.start()

See the example directory.

Handler

A handler for a given route is expected to be a function. At render time, this function will receive a context object containing a reference to the router instance and current route.

Example

    {
        router: {
            routes: {}
        },
        route: {
            path: '',
            query: {}
        }
    }

Route

The route object that's passed in the context will contain the current path, along with an object referencing any query string that was passed.

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.8

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago