Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Latest commit

 

History

History
22 lines (15 loc) · 511 Bytes

router.md

File metadata and controls

22 lines (15 loc) · 511 Bytes

Bedrock: Router

Takes care of javascript/html routing.

Uses page.js underneath.

Usage

import router from 'bedrock/src/router.js';
import mailbox from 'bedrock/src/mailbox.js';

router.add('/post/:id', ctx => console.log("Id is:", ctx.params.id));

mailbox.send('router.add', {
    route: '/post/:id',
    cb: ctx => console.log("Id is:", ctx.params.id)
});

router.start({ dispatch: true });
// Or: mailbox.send('router.start', { dispatch: true });