com.raquo.waypoint

Type members

Classlikes

sealed class CollectPageRenderer[Page, +View] extends Renderer[Page, View]
Value Params
matchRender
  • match the page and render it. This partial function should only be defined for pages that this rendered can render.
sealed class CollectPageSignalRenderer[InPage, OutPage, +View] extends Renderer[InPage, View]

The job of this renderer is to provide Signal[OutPage] => View instead of the more obvious but less efficient Signal[OutPage] => Signal[View]

The job of this renderer is to provide Signal[OutPage] => View instead of the more obvious but less efficient Signal[OutPage] => Signal[View]

It is sort of like a specialized version of Airstream .split

class ContextRouteBuilder[Bundle, Page, Ctx, CtxArgs](encodeContext: Ctx => CtxArgs, decodeContext: CtxArgs => Ctx, contextPattern: QueryParameters[CtxArgs, DummyError], pageFromBundle: Bundle => Page, contextFromBundle: Bundle => Ctx, bundleFromPageWithContext: (Page, Ctx) => Bundle)(`evidence$1`: ClassTag[Bundle], `evidence$2`: ClassTag[Ctx])

A builder for routes with context.

A builder for routes with context.

Context, in this context (heheh), is a type that encodes a set of query params that is shared between the routes created by this builder.

For example, your Laminar web app might have a big documentation section with many routes, but where every route is expected to have a "lang" query param to indicate the selected language and a "version" param to indicate the product version (unrealistic doc standards, I know).

So, you could add these two params to every page type that needs them and to every route for those page types, but that could be annoying. So instead, you could create a ContextRouteBuilder which will let you specify the necessary types / conversions / patterns only once.

See ContextRouteBuilderSpec for a concrete example.

Type Params
Bundle
  • The type of pages (including the context part) handled by the routes produced by this builder. A bundle consists of a route-specific Page, and a Context shared by all routes by this builder. In the simplest case, imagine case class Bundle(p: Page, ctx: Context)
Ctx
  • The part of the Bundle shared by all routes made by this builder, In the simplest case, imagine case class SharedParams(lang: Option[String], version: Option[String])
Page
  • The base type for the route-specific parts of the Bundle
trait Renderer[-Page, +View]
class Route[Page, Args]

Encoding and decoding are partial functions. Their partial-ness should be symmetrical, otherwise you'll end up with a route that can parse a URL into a Page but can't encode the page into the same URL (or vice versa)

Encoding and decoding are partial functions. Their partial-ness should be symmetrical, otherwise you'll end up with a route that can parse a URL into a Page but can't encode the page into the same URL (or vice versa)

Type Params
Args
  • Type of data saved in the URL for pages matched by this route Note: the Route might match only a subset of args of this type.
Page
  • Types of pages that this Route is capable of matching. Note: the Route might match only a subset of pages of this type.
Value Params
basePath
  • This string is inserted after origin. If not empty, must start with /.
decodePF
  • Decode Args into Page, if args are valid
matchEncodePF
  • Match Any to Page, and if successful, encode it into Args
Companion
object
object Route
Companion
class
class RouteEvent[BasePage](val page: BasePage, val stateData: String, val pageTitle: String, val url: String, val replace: Boolean, val fromPopState: Boolean)

This private event is fired when a route is changed.

This private event is fired when a route is changed.

class Router[BasePage](routes: List[Route[_ <: BasePage, _]], serializePage: BasePage => String, deserializePage: String => BasePage, getPageTitle: BasePage => String, routeFallback: String => BasePage, deserializeFallback: Any => BasePage)(`$popStateEvent`: EventStream[PopStateEvent], owner: Owner, val origin: String, initialUrl: String)
Value Params
$popStateEvent
  • typically windowEvents.onPopState in Laminar
deserializeFallback
  • receives raw state from History API as input and returns a page to render when the entry in the history can not be deserialized using deserializePage. If you want to perform any logic (such as redirects) in case of this fallback, put it in the renderer (whatever you have responding to router.$currentPage).
deserializePage
  • parse the result of serializePage back into a page. This is called when user navigates using browser back / forward buttons and we load history state If you throw here, deserializeFallback will be called instead.
initialUrl
origin
owner
  • typically unsafeWindowOwner in Laminar (if the router should never die, i.e. it's a whole app router)
routeFallback
  • receives URL as input (either initialUrl or on hashChange event) and returns a page to render when none of the routes match on initial page load. When rendering a fallback page, the URL will stay the same. If you want to perform any logic (such as redirects) in case of this fallback, put it in the renderer (whatever you have responding to router.$currentPage).
routes
  • List of routes that this router can handle. You should only have one router for your app, so put all your routes here. There is no concept of subrouters, this is achieved by a combination of Page type hierarchy and nested rendering signals using the patterns described in README. If none of the routes match the provided URL upon initial page load, routeFallback will be used instead.
serializePage
  • encode page into a History API state record. Return any string here (JSON string is ok) This is called any time you trigger navigation to a page.
Throws
Exception
  • when initialUrl is not absolute or does not match origin
Companion
object
object Router
Companion
class
case class SplitRender[Page, View](pageSignal: Signal[Page], renderers: List[Renderer[Page, View]])
object Utils
class Waypoint[PathErr, QueryErr, FragErr](val pathError: PathMatchingError[PathErr], val queryError: ParamMatchingError[QueryErr], val fragmentError: FragmentMatchingError[FragErr]) extends PathSegmentImpl[PathErr] with QueryParametersImpl[QueryErr] with FragmentImpl[FragErr]

Types

type FragmentPatternArgs[PathArgs, QueryArgs, FragmentArgs] = PathQueryFragmentMatching[PathArgs, QueryArgs, FragmentArgs]

A bundle of path args, query param args, and fragment args

A bundle of path args, query param args, and fragment args

type PatternArgs[PathArgs, QueryArgs] = UrlMatching[PathArgs, QueryArgs]

A bundle of path args and query param args

A bundle of path args and query param args

Value members

Concrete methods

@inline
def FragmentPatternArgs: PathQueryFragmentMatching
@inline
def PatternArgs: UrlMatching

Inherited methods

final def emptyFragment: Fragment[Unit, DummyError]

Returns a Fragment imposing that the URL does not contain any fragment.

Returns a Fragment imposing that the URL does not contain any fragment.

Note that a URL ending with "#" is considered having no fragment.

Inherited from
FragmentImpl
final def fragment[T](fromString: FromString[T, DummyError], printer: Printer[T]): Fragment[T, DummyError]

Returns a Fragment matching an element of type T. If the fragment is missing, it fails with a missing fragment error.

Returns a Fragment matching an element of type T. If the fragment is missing, it fails with a missing fragment error.

Inherited from
FragmentImpl
def listParam[Q](paramName: String)(fromString: FromString[Q, DummyError], printer: Printer[Q]): QueryParameters[List[Q], DummyError]
Inherited from
QueryParametersImpl
final def maybeFragment[T](fromString: FromString[T, DummyError], printer: Printer[T]): Fragment[Option[T], DummyError]

Returns a Fragment matching an element of type T. If the fragment is missing, it succeeds with None.

Returns a Fragment matching an element of type T. If the fragment is missing, it succeeds with None.

Inherited from
FragmentImpl
def oneOf[T](t: T, ts: T*)(fromString: FromString[T, DummyError], printer: Printer[T]): PathSegment[Unit, DummyError]
Inherited from
PathSegmentImpl
def param[Q](paramName: String)(fromString: FromString[Q, DummyError], printer: Printer[Q]): QueryParameters[Q, DummyError]
Inherited from
QueryParametersImpl
def segment[T](fromString: FromString[T, DummyError], printer: Printer[T]): PathSegment[T, DummyError]
Inherited from
PathSegmentImpl

Inherited fields

lazy val endOfSegments: PathSegment[Unit, DummyError]
Inherited from
PathSegmentImpl
val ignore: QueryParameters[Unit, DummyError]
Inherited from
QueryParametersImpl
lazy val noMatch: PathSegment[Unit, DummyError]
Inherited from
PathSegmentImpl
val remainingSegments: PathSegment[List[String], DummyError]
Inherited from
PathSegmentImpl
val root: PathSegment[Unit, DummyError]
Inherited from
PathSegmentImpl

Deprecated and Inherited fields

@deprecated("empty was poorly named, and is replaced by `ignore`. The semantic for empty might change in the future!", since = "0.3.0")
val empty: QueryParameters[Unit, DummyError]
Deprecated
[Since version 0.3.0]
Inherited from
QueryParametersImpl

Implicits

Inherited implicits

final implicit def asFragment[T](t: T)(fromString: FromString[T, DummyError], printer: Printer[T], classTag: ClassTag[T]): Fragment[Unit, DummyError]
Inherited from
FragmentImpl
implicit def unaryPathSegment[T](t: T)(fromString: FromString[T, DummyError], printer: Printer[T]): PathSegment[Unit, DummyError]
Inherited from
PathSegmentImpl