Class/Object

japgolly.scalajs.react.extra.router.StaticDsl

Rule

Related Docs: object Rule | package StaticDsl

Permalink

final case class Rule[Page](parse: (Path) ⇒ Option[Parsed[Page]], path: (Page) ⇒ Option[Path], action: (Path, Page) ⇒ Option[Action[Page]]) extends Product with Serializable

A single routing rule. Intended to be composed with other Rules. When all rules are composed, this is turned into a Rules instance.

Page

The type of legal pages.

parse

Attempt to parse a given path.

path

Attempt to determine the path for some page.

action

Attempt to determine the action when a route resolves to some page.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Rule
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Rule(parse: (Path) ⇒ Option[Parsed[Page]], path: (Page) ⇒ Option[Path], action: (Path, Page) ⇒ Option[Action[Page]])

    Permalink

    parse

    Attempt to parse a given path.

    path

    Attempt to determine the path for some page.

    action

    Attempt to determine the action when a route resolves to some page.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val action: (Path, Page) ⇒ Option[Action[Page]]

    Permalink

    Attempt to determine the action when a route resolves to some page.

  5. def addCondition(cond: (Page) ⇒ CallbackTo[Boolean])(condUnmet: (Page) ⇒ Option[Action[Page]]): Rule[Page]

    Permalink

    Prevent this rule from functioning unless some condition holds, passes in the page requested as part of the context.

    Prevent this rule from functioning unless some condition holds, passes in the page requested as part of the context. When the condition doesn't hold, an alternative action may be performed.

    cond

    Function that takes the requested page and returns true if the page should be rendered.

    condUnmet

    Response when rule matches but condition doesn't hold. If response is None it will be as if this rule doesn't exist and will likely end in the route-not-found fallback behaviour.

  6. def addCondition(cond: CallbackTo[Boolean])(condUnmet: (Page) ⇒ Option[Action[Page]]): Rule[Page]

    Permalink

    Prevent this rule from functioning unless some condition holds.

    Prevent this rule from functioning unless some condition holds. When the condition doesn't hold, an alternative action may be performed.

    condUnmet

    Response when rule matches but condition doesn't hold. If response is None it will be as if this rule doesn't exist and will likely end in the route-not-found fallback behaviour.

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def autoCorrect(redirectMethod: Method): Rule[Page]

    Permalink

    When a route matches a page, compare its Path to what the route would generate for the same page and if they differ, redirect to the generated one.

    When a route matches a page, compare its Path to what the route would generate for the same page and if they differ, redirect to the generated one.

    Example: If a route matches /issue/dev-23 and returns a Page("DEV", 23) for which the generate path would be /issue/DEV-23, this would automatically redirect /issue/dev-23 to /issue/DEV-23, and process /issue/DEV-23 normally using its associated action.

  9. def autoCorrect: Rule[Page]

    Permalink

    See autoCorrect().

  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def fallback(fp: (Page) ⇒ Path, fa: (Path, Page) ⇒ Action[Page]): Rules[Page]

    Permalink

    Specify behaviour when a Page doesn't have an associated Path or Action.

  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. def modPath(add: (Path) ⇒ Path, remove: (Path) ⇒ Option[Path]): Rule[Page]

    Permalink

    Modify the path(es) generated and parsed by this rule.

  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. def noFallback: Rules[Page]

    Permalink

    When a Page doesn't have an associated Path or Action, throw a runtime error.

    When a Page doesn't have an associated Path or Action, throw a runtime error.

    This is the trade-off for keeping the parsing and generation of known Pages in sync - compiler proof of Page exhaustiveness is sacrificed.

    It is recommended that you call RouterConfig.verify as a sanity-check.

  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. val parse: (Path) ⇒ Option[Parsed[Page]]

    Permalink

    Attempt to parse a given path.

  22. val path: (Page) ⇒ Option[Path]

    Permalink

    Attempt to determine the path for some page.

  23. def pmap[W](f: (Page) ⇒ W)(pf: PartialFunction[W, Page]): Rule[W]

    Permalink
  24. def pmapCT[W](f: (Page) ⇒ W)(implicit ct: ClassTag[Page]): Rule[W]

    Permalink
  25. def pmapF[W](f: (Page) ⇒ W)(g: (W) ⇒ Option[Page]): Rule[W]

    Permalink
  26. def prefixPath(prefix: String): Rule[Page]

    Permalink

    Add a prefix to the path(es) generated and parsed by this rule.

  27. def prefixPath_/(prefix: String): Rule[Page]

    Permalink

    Add a prefix to the path(es) generated and parsed by this rule.

    Add a prefix to the path(es) generated and parsed by this rule.

    Unlike prefixPath() when the suffix is non-empty, a slash is added between prefix and suffix.

  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. def widen[W >: Page](pf: PartialFunction[W, Page]): Rule[W]

    Permalink
  33. def widenCT[W >: Page](implicit ct: ClassTag[Page]): Rule[W]

    Permalink
  34. def widenF[W >: Page](f: (W) ⇒ Option[Page]): Rule[W]

    Permalink
  35. def xmap[A](f: (Page) ⇒ A)(g: (A) ⇒ Page): Rule[A]

    Permalink
  36. def |(that: Rule[Page]): Rule[Page]

    Permalink

    Compose rules.

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped