Class Router

micro router

const router = new Router( );

router.get( "/detail/:id", ( params: any ) => {
this._showDetail( detail );
} );

router.get( "/:id", ( params: any ) => {
if( params.id==0 )
router.navigate( '/home' );
}
});

router.on( "error", ( ) => {
router.navigate( '/home' );
})

router.init( );

Hierarchy

Constructors

Properties

m_routes: Route[]
m_useHash: boolean

Methods

  • Parameters

    • url: string

    Returns {
        handlers: RouteHandler[];
        params: any;
    }

    • handlers: RouteHandler[]
    • params: any
  • emit an event you can stop propagation of event or prevent default

    Type Parameters

    • K extends "error"

    Parameters

    • type: K
    • Optional event: RouterEventMap[K]

      event data

    Returns void

  • Parameters

    • uri: string | RegExp
    • handler: RouteHandler

    Returns void

  • Parameters

    • uri: string
    • notify: boolean = true
    • replace: boolean = false

    Returns void

  • stop listening to an event

    Type Parameters

    • K extends "error"

    Parameters

    • type: K
    • callback: ((ev) => any)

      callback to remove (must be the same as in on )

        • (ev): any
        • Parameters

          • ev: RouterEventMap[K]

          Returns any

    Returns void

  • handle an event one time

    Type Parameters

    • K extends "error"

    Parameters

    • type: K
    • callback: ((ev) => any)

      callback to call when event is signaled

        • (ev): any
        • Parameters

          • ev: RouterEventMap[K]

          Returns any

    Returns void

    Promise if callback is null

    take care with that because if the event is never fired and you await it, the system may overflow

  • signal en event signaled event are notification : no way to prevent default not stop propagation

    Type Parameters

    • K extends "error"

    Parameters

    • type: K
    • event: RouterEventMap[K]

      event data

    • delay: number = -1

    Returns void

Generated using TypeDoc