package browser
- Alphabetic
- By Inheritance
- browser
- Router
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- case class ParsedPathParts(segments: Seq[String], hash: Option[String], params: Map[String, Array[String]], pathname: String) extends Product with Serializable
Query parameters broken out.
- case class PathParts(segments: Seq[String], hash: Option[String], search: Option[String], pathname: String) extends Product with Serializable
Specification of a specific set of information for routing.
Specification of a specific set of information for routing. This one is mostly based on the DOM but its contents can be generically used in most cases.
- trait ReactionRouterDOMComponent extends RoutingSourceComponent[PathParts, String] with RoutingConfig[PathParts, String]
Routing using this facade's router context provider and targeted for the DOM and browser URLs.
Routing using this facade's router context provider and targeted for the DOM and browser URLs. You don't need this class, you could just listen to the history changes using a browser's history API or the "history" js package. Use a instance of this component as an ancestor to provide the latest "history" location in a react context then use the
Route
component, a value dependent type, to perform routing anywhere in the application. The F context is Id so there is no effect wrapping a rule's Action.You may also want to look at the code behind the [history github](https://github.com/ReactTraining/history) package or [react-router-navigation-prompt](https://github.com/ZacharyRSmith/react-router-navigation-prompt) in order to see how to take an user confirmed action such as saving changes before routing away. If you roll your own, you will need to register an "beforeonload" handler with the window when the user types in a new URL and throw up a dialog. You can also register with the document's history object to indepdently listen to history changes and if the URLs are different, throw up a dialog.
- sealed trait Redirect extends AnyRef
- trait Router extends AnyRef
Simple router as in ReasonReact.
Simple router as in ReasonReact. Use pattern matching in the callbacok to match on the url structure
(path seq, hash, search)
and then call "send" on your component's router. This is not meant to be a robust router implementation, just some abstraction over thewindow.history
api. You could define your own e.g. a stream of history changes.- To do
Add PathParts type parameter.
Flexibly determine of window and history API exists before calling methods.
- trait RoutingConfig[Info <: AnyRef, To] extends AnyRef
A collection of routing config types so you can compose routing rules.
A collection of routing config types so you can compose routing rules. The rules do not prescribe a specific "Info" to "Action" matching model so you are free to choose your own. You can use sparse.tech [trail](https://github.com/sparsetech) or something like [path-to-regexp](https://github.com/pillarjs/path-to-regexp). Also, look at [You might not need React Router](https://medium.freecodecamp.org/you-might-not-need-react-router-38673620f3d) for ideas. That article uses an array of regexp to async functions vs a total function descibed in
Rules
below. Since the returned action is warpped in aF
, any router using this trait will need to know how to runF
.- Info
The request info pushed from the routing source.
- To
A value representing where to go to.
- trait RoutingSource[Info, To] extends AnyRef
A specific abstraction of a "routers" source of routing events.
A specific abstraction of a "routers" source of routing events. You can use reaction's router but you can also use something like [history](https://github.com/ReactTraining/history) by defining your own RoutingSource. The underlying routing subsystem should support the notion of a stack of requested routes--yes, very DOM'ish. This API is a bit crude and should be type of observable reactive object that bakes in failure semantics more clearly. The burden of remembering the last routing info is put on the RoutingComponent instead of the RoutingSource where it belongs :-(. Note that this is not very functional.
- Info
Routing event from an external thing such as an agent e.g. someone types a URL into a class.
- To
Data needed to change the current route.
- To do
Make this reactive and get rid of this awful API.
- trait RoutingSourceComponent[Info <: AnyRef, To] extends AnyRef
Subscribe to a RoutingSource and establish a react routing context.
Subscribe to a RoutingSource and establish a react routing context. Unsubscribe on unmount. Children can be anything but look at
ShowIfMatch
or an inside component in any subclasses e.g.Route
inReactionRoutingDOMComponent
. - class URLSearchParams extends Object
- Annotations
- @JSType() @native() @JSGlobal("URLSearchParams")
- type WatcherId = Any
- Definition Classes
- Router
Value Members
- def dangerouslyGetUrl(): PathParts
Get the current url.
Get the current url. It's dangerous because it could be out of date.
- Definition Classes
- Router
- def push(path: String): Unit
- Definition Classes
- Router
- def replace(path: String): Unit
- Definition Classes
- Router
- def unwatchUrl(watcherId: WatcherId): Unit
- Definition Classes
- Router
- def watchUrl(cb: (PathParts) => Unit): WatcherId
Add your call back using
watchUrl{case (path, hash, search) => ... }
.Add your call back using
watchUrl{case (path, hash, search) => ... }
.- Definition Classes
- Router
- object PostRenderer
- object ReactionRouter extends ReactionRouterDOMComponent
- object Redirect