(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.
(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.
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.
(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.
(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.
(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).
(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.
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.
(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.
(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.
(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.
(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.
(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.
(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.
(route-handler {:com.fulcrologic.fulcro.ui-state-machines/keys [app event-data]
:as env})
(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.
(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.
Mutation: Indicate that a target is ready.
Mutation: Indicate that a target is ready.
(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.
(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.
(will-enter class app params)
Universal CLJC version of will-enter.
Universal CLJC version of will-enter.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close