Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.routing.dynamic-routing


accepts-route?clj/s

(accepts-route? component path)

Returns true if the given component is a router that manages a route target that will accept the given path.

Returns true if the given component is a router that manages a route target that will accept the given path.
sourceraw docstring

all-reachable-routersclj/s

(all-reachable-routers state-map component-class)

Returns a sequence of all of the routers reachable in the query of the app.

Returns a sequence of all of the routers reachable in the query of the app.
sourceraw docstring

apply-routeclj/s

Mutation: Indicate that a given route is ready and should show the result.

router - The ident of the router, with metadata :component that is the class of the router. target - The ident of the target route, with metadata :component that is the class of the target.

Mutation: Indicate that a given route is ready and should show the result.

router - The ident of the router, with metadata :component that is the class of the router.
target - The ident of the target route, with metadata :component that is the class of the target.
sourceraw docstring

ast-node-for-live-routerclj/s

(ast-node-for-live-router app {:keys [component children] :as ast-node})

Returns the AST node for a query that represents the closest "live" (on-screen) router

ast - A query AST node

Returns an AST node or nil if none is found.

Returns the AST node for a query that represents the closest "live" (on-screen) router

ast - A query AST node

Returns an AST node or nil if none is found.
sourceraw docstring

ast-node-for-routeclj/s

(ast-node-for-route {:keys [component children] :as ast-node} path)

Returns the AST node for a query that represents the router that has a target that can accept the given path. This is a breadth-first search.

ast - A query AST node path - A vector of the current URI segments.

Returns an AST node or nil if none is found.

Returns the AST node for a query that represents the router that has a target that can accept the given path. This is a breadth-first
search.

ast - A query AST node
path - A vector of the current URI segments.

Returns an AST node or nil if none is found.
sourceraw docstring

change-routeclj/s

(change-route this new-route)
(change-route this new-route timeouts)

Trigger a route change.

this - The component (or app) that is causing the route change. new-route - A vector of URI components to pass to the router. timeouts - A map of timeouts that affect UI during deferred routes: {:error-timeout ms :deferred-timeout ms}

The error timeout is how long to wait (default 5000ms) before showing the error-ui of a route (which must be defined on the router that is having problems). The deferred-timeout (default 100ms) is how long to wait before showing the loading-ui of a deferred router (to prevent flicker).

Trigger a route change.

this - The component (or app) that is causing the route change.
new-route - A vector of URI components to pass to the router.
timeouts - A map of timeouts that affect UI during deferred routes: {:error-timeout ms :deferred-timeout ms}

The error timeout is how long to wait  (default 5000ms) before showing the error-ui of a route (which must be defined on the
router that is having problems).  The deferred-timeout (default 100ms) is how long to wait before showing the loading-ui of
a deferred router (to prevent flicker).
sourceraw docstring

change-route-relativeclj/s

(change-route-relative this-or-app relative-class-or-instance new-route)
(change-route-relative app-or-comp
                       relative-class-or-instance
                       new-route
                       timeouts)

Change the route, starting at the given Fulcro class or instance (scanning for the first router from there). new-route is a vector of string components to pass through to the nearest child router as the new path. The first argument is any live component or the app. The timeouts are as in change-route. It is safe to call this from within a mutation.

When possible (i.e. no circular references to components) you can maintain better code navigation by generating new-route via path-to. This will allow readers of your code to quickly jump to the actual components that implement the targets when reading the code.

Change the route, starting at the given Fulcro class or instance (scanning for the first router from there).  `new-route` is a vector
of string components to pass through to the nearest child router as the new path. The first argument is any live component
or the app.  The `timeouts` are as in `change-route`.
It is safe to call this from within a mutation.

When possible (i.e. no circular references to components) you can maintain better code navigation by
generating `new-route` via `path-to`.  This will allow readers of your code to quickly jump to the actual
components that implement the targets when reading the code.
sourceraw docstring

compile-errorclj

(compile-error env form message)
source

current-routeclj/s

(current-route this-or-app relative-class-or-instance)

Returns the current active route, starting from the relative Fulcro class or instance.

Any component using this as a basis for rendering will need to add the following to their query to ensure the props of that component change on route changes:

[::uism/asm-id fq-router-kw]

where fq-router-kw is a keyword that has the exact namespace and name of the router you're interested in. If you want to just over-render you can use a quoted _ instead.

Returns the current active route, starting from the relative Fulcro class or instance.

Any component using this as a basis for rendering will need to add the following to their query to
ensure the props of that component change on route changes:

```
[::uism/asm-id fq-router-kw]
```

where `fq-router-kw` is a keyword that has the exact namespace and name of the router you're interested in. If you want
to just over-render you can use a quoted `_` instead.
sourceraw docstring

current-route-classclj/s

(current-route-class this)

Get the class of the component that is currently being routed to.

Get the class of the component that is currently being routed to.
sourceraw docstring

defrouterclj/smacro

(defrouter router-sym arglist options & body)

Define a router.

The arglist is [this props], which are just like defsc. The props will contains :current-state and :pending-path-segment.

The options are:

:router-targets - (REQUIRED) A vector of ui components that are router targets. The first one is considered the "default". Other defsc options - (LIMITED) You may not specify query/initial-state/protocols/ident, but you can define things like react lifecycle methods. See defsc.

The optional body, if defined, will only be used if the router is in one of the following states:

  • :initial - No route is set.
  • :pending - A deferred route is taking longer than expected (configurable timeout, default 100ms)
  • :failed - A deferred route took longer than can reasonably be expected (configurable timeout, default 5s)

otherwise the actual active route target will be rendered.

Define a router.

The arglist is `[this props]`, which are just like defsc. The props will contains :current-state and :pending-path-segment.

The options are:

`:router-targets` - (REQUIRED) A *vector* of ui components that are router targets. The first one is considered the "default".
Other defsc options - (LIMITED) You may not specify query/initial-state/protocols/ident, but you can define things like react
lifecycle methods. See defsc.

The optional body, if defined, will *only* be used if the router is in one of the following states:

- `:initial` - No route is set.
- `:pending` - A deferred route is taking longer than expected (configurable timeout, default 100ms)
- `:failed` - A deferred route took longer than can reasonably be expected (configurable timeout, default 5s)

otherwise the actual active route target will be rendered.
sourceraw docstring

defrouter*clj

(defrouter* env router-ns router-sym arglist options body)
source

fail-handlerclj/s

(fail-handler env)
source

get-route-cancelledclj/s

(get-route-cancelled class)

Returns the function that should be called if this target was in a deferred state and a different routing choice was made. Is given the same route parameters that were sent to will-enter.

Returns the function that should be called if this target was in a deferred state and a different routing choice was made. Is given the same route parameters that were sent to `will-enter`.
sourceraw docstring

get-targetsclj/s

(get-targets router)

Returns a set of classes to which this router routes.

Returns a set of classes to which this router routes.
sourceraw docstring

get-will-enterclj/s

(get-will-enter class)

Returns the function that is called before a route target is activated (if the route segment of interest has changed and the target of the result is this target). MUST return (r/route-immediate ident) or (r/route-deferred ident) to indicate what ident should be used in app state to connect the router's join. If deferred, the router must cause a call to the r/target-ready mutation (or use the target-ready* mutation helper) with a {:target ident} parameter to indicate that the route target is loaded and ready for display.

params will be a map from any keywords found in route-segment to the string value of that path element.

WARNING: This method MUST be side-effect free.

Returns the function that is called before a route target is activated (if the route segment of interest has changed and the
target of the result is this target).  MUST return (r/route-immediate ident) or (r/route-deferred ident) to indicate
what ident should be used in app state to connect the router's join.  If deferred, the router must cause a call to
the r/target-ready mutation (or use the target-ready* mutation helper) with a {:target ident} parameter to indicate
that the route target is loaded and ready for display.

`params` will be a map from any keywords found in `route-segment` to the string value of that path element.

WARNING: This method MUST be side-effect free.
sourceraw docstring

get-will-leaveclj/s

(get-will-leave this)

Returns the function of a route target to be called with the current component and props. If it returns true then the routing operation will continue. If it returns false then whatever new route was requested will be completely abandoned. It is the responsibility of this method to give UI feedback as to why the route change was aborted.

Returns the function of a route target to be called with
the current component and props. If it returns `true` then the routing operation will continue.  If it returns `false`
then whatever new route was requested will be completely abandoned.  It is the responsibility of this method to give
UI feedback as to why the route change was aborted.
sourceraw docstring

immediate?clj/s

(immediate? ident)
source

initialize!clj/s

(initialize! app)

Initialize the routing system. This ensures that all routers have state machines in app state.

Initialize the routing system.  This ensures that all routers have state machines in app state.
sourceraw docstring

into-pathclj/s

(into-path prefix TargetClass & path-args)

Returns the given prefix with the TargetClass segment appended onto it, replacing the final elements with the given (optional) path args.

(defsc X [_ _]
  {:route-segment ["a" :b]})

(into ["f" "g"] X "22") ; => ["f" "g" "a" "22"]
Returns the given `prefix` with the TargetClass segment appended onto it, replacing the final elements with the
 given (optional) path args.

```
(defsc X [_ _]
  {:route-segment ["a" :b]})

(into ["f" "g"] X "22") ; => ["f" "g" "a" "22"]
```
sourceraw docstring

mark-route-pending*clj/s

(mark-route-pending* state-map {:keys [router target] :as params})
source

matching-prefixclj/s

(matching-prefix route-segment actual-path)

Returns the elements of actual-path that match the route-segment definition.

Returns the elements of actual-path that match the route-segment definition.
sourceraw docstring

path-toclj/s

(path-to & targets-and-params)

Convert a sequence of router targets and parameters into a vector of strings that represents the target route. Parameters can be sequenced inline:

(defsc A [_ _]
  {:route-segment ["a" :a-param]})

(defsc B [_ _]
  {:route-segment ["b" :b-param]})

(route-segment A a-param1 B b-param ...)

where the parameters for a target immediately follow the component that requires them. Alternatively one can specify all of the parameters at the end as a single map using the parameter names that are used in the component :route-segment itself:

(defsc A [_ _]
  {:route-segment ["a" :a-param]})

(route-segment A B C D {:a-param 1})
Convert a sequence of router targets and parameters into a vector of strings that represents the target route. Parameters
can be sequenced inline:

```
(defsc A [_ _]
  {:route-segment ["a" :a-param]})

(defsc B [_ _]
  {:route-segment ["b" :b-param]})

(route-segment A a-param1 B b-param ...)
```

where the parameters for a target immediately follow the component that requires them. Alternatively
one can specify all of the parameters at the end as a single map using the parameter names that are used in
the component `:route-segment` itself:

```
(defsc A [_ _]
  {:route-segment ["a" :a-param]})

(route-segment A B C D {:a-param 1})
```
sourceraw docstring

proposed-new-pathclj/s

(proposed-new-path this-or-app relative-class-or-instance new-route)

Internal algorithm: Returns a sequence of idents of the targets that the new-route goes through by analyzing the current application query and state.

Internal algorithm: Returns a sequence of idents of the targets that the `new-route` goes through by analyzing the current
application query and state.
sourceraw docstring

ready-handlerclj/s

(ready-handler env)
source

route-cancelledclj/s

(route-cancelled class route-params)

Universal CLJC version of will-enter. Don't use the protocol method in CLJ.

Universal CLJC version of will-enter.  Don't use the protocol method in CLJ.
sourceraw docstring

route-deferredclj/s

(route-deferred ident completion-fn)
source

route-handlerclj/s

(route-handler {:com.fulcrologic.fulcro.ui-state-machines/keys [app event-data]
                :as env})
source

route-immediateclj/s

(route-immediate ident)
source

route-lifecycle?clj/s

(route-lifecycle? component)
source

route-segmentclj/s

(route-segment class)

Returns a vector that describes the sub-path that a given route target represents. String elements represent explicit path elements, and keywords represent variable values (which are always pulled as strings).

Returns a vector that describes the sub-path that a given route target represents. String elements represent
explicit path elements, and keywords represent variable values (which are always pulled as strings).
sourceraw docstring

route-targetclj/s

(route-target router-class path)

Given a router class and a path segment, returns the class of the router-class that is the target of the given URI path, which is a vector of (string) URI components.

Returns nil if there is no target that accepts the path, or a map containing:

{:target class :matching-prefix prefix}

where class is the component class that accepts the path (the target, NOT the router), and matching-prefix is the portion of the path that is accepted by that class.

NOTE: If more than one target matches, then the target with the longest match will be returned. A warning will be printed if more than one match of equal length is found.

Given a router class and a path segment, returns the class of the router-class that is the target of the given URI path,
which is a vector of (string) URI components.

Returns nil if there is no target that accepts the path, or a map containing:

{:target class
 :matching-prefix prefix}

where `class` is the component class that accepts the path (the target, NOT the router), and `matching-prefix` is the
portion of the path that is accepted by that class.

NOTE: If more than one target matches, then the target with the longest match will be returned. A warning will be
printed if more than one match of equal length is found.
sourceraw docstring

route-target?clj/s

(route-target? component)
source

router-for-pending-targetclj/s

(router-for-pending-target state-map target)
source

router?clj/s

(router? component)
source

RouterStateMachineclj/s

source

signal-router-leavingclj/s

(signal-router-leaving app-or-comp relative-class-or-instance new-route)

Tell active routers that they are about to leave the screen. Returns false if any of them deny the route change.

Tell active routers that they are about to leave the screen. Returns false if any of them deny the route change.
sourceraw docstring

subpathclj/s

(subpath TargetClass & path-args)

Returns the route segment of the given TargetClass with the trailing elements replaced by path-args.

(defsc X [_ _]
  {:route-segment ["a" :b]})

(subpath X "22") ; => ["a" "22"]
Returns the route segment of the given TargetClass with the trailing elements replaced by path-args.

```
(defsc X [_ _]
  {:route-segment ["a" :b]})

(subpath X "22") ; => ["a" "22"]
```
sourceraw docstring

target-readyclj/s

Mutation: Indicate that a target is ready.

Mutation: Indicate that a target is ready.
sourceraw docstring

target-ready!clj/s

(target-ready! component-or-app target)

Indicate a target is ready. Safe to use from within mutations.

target - The ident that was originally listed as a deferred target.

Indicate a target is ready.  Safe to use from within mutations.

target - The ident that was originally listed as a deferred target.
sourceraw docstring

validate-route-targetsclj/s

(validate-route-targets router-instance)

Run a runtime validation on route targets to verify that they at least declare a route-segment that is a vector.

Run a runtime validation on route targets to verify that they at least declare a route-segment that is a vector.
sourceraw docstring

will-enterclj/s

(will-enter class app params)

Universal CLJC version of will-enter.

Universal CLJC version of will-enter.
sourceraw docstring

will-leaveclj/s

(will-leave c props)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close