An individual item that will be displayed by a RouterNavigator component. Provides the URL path pattern, the view, and an optional list of events to map to actions (like push or pop navigation) performed by the RouterNavigator.

To determine which Route to use, the RouterNavigator matches the current URL against the path patterns defined by the Route objects.

Path patterns must start with a forward slash / character. Do not include the host/domain part of the URL.

Path patterns support named parameters that start with a : colon character. For example, the path pattern /:foo/:bar has named parameters with the names "foo" and "bar". If the display object returned by the Route implements the IRouteView interface, the name parameters are passsed to the view for additional parsing.

Named parameters may be made optional by appending a ? question mark character. For example, the "foo" parameter is optional in the path pattern /baz/:foo?, and it will also match "/baz" without the parameter.

If the path pattern is null or an empty string, it will always match.

If the RouterNavigator defines a basePath, path patterns should not include the base path. It will be handled automatically.

Available since

1.0.0

.

See also:

Static methods

staticwithClass<T>(path:String, viewClass:Class<T>, ?actions:Map<String, RouterAction>, ?updateState:(view:T, state:RouteState) ‑> Void, ?saveData:(view:T) ‑> Dynamic, ?restoreData:(view:T, data:Dynamic) ‑> Void):Route

Creates a Route that instantiates a view from a class that extends DisplayObject when the RouterNavigator requests the item's view.

staticwithDisplayObject<T>(path:String, viewInstance:T, ?actions:Map<String, RouterAction>, ?updateState:(view:T, state:RouteState) ‑> Void, ?saveData:(view:T) ‑> Dynamic, ?restoreData:(view:T, data:Dynamic) ‑> Void):Route

Creates a Route that always returns the same DisplayObject instance when the RouterNavigator requests the item's view.

staticwithFunction<T>(path:String, viewFunction:() ‑> T, ?actions:Map<String, RouterAction>, ?updateState:(view:T, state:RouteState) ‑> Void, ?saveData:(view:T) ‑> Dynamic, ?restoreData:(view:T, data:Dynamic) ‑> Void):Route

Creates a Route that calls a function that returns a DisplayObject when the RouterNavigator requests the item's view.

staticwithRedirect(path:String, redirectTo:String):Route

Creates a Route that redirects to a different path.

Variables

path:String

The URL path associated with this route.

Available since

1.0.0

.

Methods

dynamicinjectState(view:Dynamic, routeState:RouteState):Void

Deprecated: "Route.injectState is deprecated. Use Route.updateState() and RouteState.historyState instead."

An optional function to parse the current history state when a view is shown.

This function must be able to handle null state.

Available since

1.0.0

.

dynamicrestoreData(view:Dynamic, data:Dynamic):Void

Deprecated: "Route.restoreData is deprecated. Use Route.updateState() and RouteState.data instead."

An optional function to restore the view's data before navigating away.

This function must be able to handle null data.

Available since

1.0.0

.

dynamicsaveData(view:Dynamic):Dynamic

An optional function to save the view's data before navigating away.

Available since

1.0.0

.

setAction(eventType:String, action:RouterAction):Void

Sets a new action to perform when the view dispatches an event. If the action is null, removes an action that was set previously.

Available since

1.0.0

.

dynamicupdateState(view:Dynamic, routeState:RouteState):Void

An optional function to customize the view before it is shown.

Available since

1.0.0

.