@arco-tech/mithril-router
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

mithril-router.js

Mithril.js router wrapper with added functionality

Installation

npm i @arco-tech/mithril-router

or

yarn i @arco-tech/mithril-router

Usage

import { Router } from "@arco-tech/mithril-router"

import { HomeScreen } from "./screens/home_screen"
import { PostsScreen } from "./screens/posts_screen"
import { PostScreen } from "./screens/post_screen"

const router = new Router({
  prefix: "",
  routes: [
    { id: "home", path: "", component: HomeScreen },
    { id: "posts", path: "/posts", component: PostsScreen },
    { id: "post", path: "/posts/:id", component: PostScreen },
  ],
})

router.init(document.body) // calls m.route()

router.path("posts")
// "/posts"

router.path("posts", { q: "test", limit: 10 })
// "/posts?q=test&limit=10"

router.path("post", { id: 123, overlay: "update" })
// "/posts/123?overlay=update"

router.route("post", { id: 123 }) // calls m.route.set()

Package Sidebar

Install

npm i @arco-tech/mithril-router

Weekly Downloads

1

Version

0.1.6

License

MIT

Unpacked Size

25.5 kB

Total Files

16

Last publish

Collaborators

  • arco-team