Normally Pleasant Mixture

    @domodel/router

    1.0.49 • Public • Published

    domodel-router

    URL routing system for domodel.

    Getting started

    Prerequisites

    Installing

    npm install @domodel/router

    Usage

    import { Core, Model } from "domodel"
    import { Router, Route, RouterModel, RouterBinding } from "@domodel/router"
    
    import MyViewModel from "/model/my-view.js"
    import MyViewModel2 from "/model/my-view2.js"
    
    import MyViewBinding from "/model/my-view.binding.js"
    import MyView2Binding from "/model/my-view2.binding.js"
    
    const routes = [
      new Route({
        match: "/", 
        model: new Model(MyViewModel, MyViewBinding)
      }),
      new Route({
        match: "/test", 
        model: new Model(MyViewModel2, MyView2Binding)
      })
    ]
    
    window.addEventListener("load", function() {
    
      const router = new Router({
        routes, 
        type: Router.TYPE.HASH
      })
    
      Core.run(RouterModel, {
        binding: new RouterBinding({ router }),
        parentNode: document.body
      })
    })

    See route-tokenizer for route format.

    Keywords

    none

    Install

    npm i @domodel/router

    DownloadsWeekly Downloads

    2

    Version

    1.0.49

    License

    MIT

    Unpacked Size

    41.8 kB

    Total Files

    30

    Last publish

    Collaborators

    • thoughtsunificator