Interface CrossRoadsStatic

Index

Properties

Methods

Properties

public NORM_AS_ARRAY: Function

public NORM_AS_OBJECT: Function

public VERSION: string

String representation of the crossroads version number (e.g. "0.6.0").

public bypassed: Signal

Signal dispatched every time that crossroads.parse can't find a Route that matches the request. Useful for debuging and error handling.

public greedy: boolean

Sets global route matching behavior to greedy so crossroads will try to match every single route with the supplied request (if true it won't stop at first match).

public greedyEnabled: boolean

Sets if the greedy routes feature is enabled. If false it won't try to match multiple routes (faster).

public ignoreState: boolean

Sets if Router should care about previous state, so multiple crossroads.parse() calls passing same argument would not trigger the routed, matched and bypassed signals.

public normalizeFn: Function

Sets a default function that should be used to normalize parameters before passing them to the Route.matched, works similarly to Route.rules.normalize_.

public routed: Signal

Signal dispatched every time that crossroads.parse find a Route that matches the request. Useful for debuging and for executing tasks that should happen at each routing.

public shouldTypecast: boolean

Set if crossroads should typecast route paths. Default value is false (IMPORTANT: on v0.5.0 it was true by default).

Methods

public addRoute(pattern: any, handler?: Function, priority?: number): Route

Creates a new route pattern listener and add it to crossroads routes collection.

Parameters

  • pattern: any

    String pattern or Regular Expression that should be used to match against requests.

  • handler?: Function optional

    Function that should be executed when a request matches the Route pattern.

  • priority?: number optional

    Route execution priority.

Returns

Route

public create(): CrossRoadsStatic

Create a new independent Router instance.

Returns

CrossRoadsStatic

public getNumRoutes(): number

Get number of Routes contained on the crossroads collection.

Returns

number

public parse(request: string, defaultArgs?: Array<any>): any

Parse a string input and dispatch matched Signal of the first Route that matches the request.

Parameters

  • request: string

    String that should be evaluated and matched against Routes to define which Route handlers should be executed and which parameters should be passed to the handlers.

  • defaultArgs?: Array<any> optional

Returns

any

public pipe(router: CrossRoadsStatic): any

Pipe routers, so all crossroads.parse() calls will be forwarded to the other router as well.

Parameters

Returns

any

public removeAllRoutes(): any

Remove all routes from crossroads collection.

Returns

any

public removeRoute(route: Route): any

Remove a single route from crossroads collection.

Parameters

  • route: Route

    Reference to the Route object returned by crossroads.addRoute().

Returns

any

public resetState(): any

Resets the Router internal state. Will clear reference to previously matched routes (so they won't dispatch switched signal when matching a new route) and reset last request.

Returns

any

public unpipe(router: CrossRoadsStatic): any

"Ceci n'est pas une pipe"

Parameters

Returns

any