Liking cljdoc? Tell your friends :D

fulcro.client.routing


add-route-stateclj/s

(add-route-state state-map target-kw component)
source

bad-routeclj/s

(bad-route page)
source

coerce-paramclj/smultimethod

source

current-routeclj/s

(current-route state-map-or-router-table router-id)

Get the current route (an ident) from the router with the given id. You can pass the entire app database, the routers table, or the props of a component that has queried for the router table as the first argument to this function. Thus, it can be used easily from within a mutation or in a component to find (and display) the current route:

(defmutation do-something-with-routes [params]
  (action [{:keys [state]}]
    (let [current (r/current-route state :top-router)]
    ...)))

(defsc NavBar [this props]
  {:query (fn [] [[r/routers-table '_]])
   :initial-state (fn [params] {})}
  (let [current (r/current-route props :top-router)]
    ...))
Get the current route (an ident) from the router with the given id. You can pass the entire app database, the routers table,
or the props of a component that has queried for the router table as the first argument to this function.
Thus, it can be used easily from within a mutation or in a component to find (and display) the current route:

```
(defmutation do-something-with-routes [params]
  (action [{:keys [state]}]
    (let [current (r/current-route state :top-router)]
    ...)))

(defsc NavBar [this props]
  {:query (fn [] [[r/routers-table '_]])
   :initial-state (fn [params] {})}
  (let [current (r/current-route props :top-router)]
    ...))
```
sourceraw docstring

defrouterclj/smacro

(defrouter & args)

Generates a component with a union query that can route among the given screens.

(defrouter ComponentName keyword-for-router-id
  ident-generator
  kw Component
  kw2 Component2
  ...)

The first screen listed will be the 'default' screen that the router will be initialized to show.

The ident-generator can be:

. A lamba receiving this and props that must return a legal ident from the props of any of the listed components . A vector listing the table prop and id prop that will be in the state of the screen

Examples:

(fn [this props] [(:screen props) (:id props)]) ; General-purpose [:screen :id] ; shorthand for prior example (fn [t p] [(:screen p :constant-id]) ; must use fn form if id is some kind of constant (ident [t p] [(:screen p) :x]) ; name of the lambda is ignored (fn is recommended) ...

NOTES:

  • All Component screens must have initial state
  • All Component screens must have a query
  • All Component screens must have state that the ident-fn can use to generate a proper ident from your ident generator.
Generates a component with a union query that can route among the given screens.

```
(defrouter ComponentName keyword-for-router-id
  ident-generator
  kw Component
  kw2 Component2
  ...)
```

The first screen listed will be the 'default' screen that the router will be initialized to show.

The `ident-generator` can be:

. A lamba receiving `this` and `props` that must return a legal ident from the props of any of the listed components
. A vector listing the table prop and id prop that will be in the state of the screen

Examples:

(fn [this props] [(:screen props) (:id props)])  ; General-purpose
[:screen :id]                                    ; shorthand for prior example
(fn [t p] [(:screen p :constant-id])             ; must use fn form if id is some kind of constant
(ident [t p] [(:screen p) :x])                   ; name of the lambda is ignored (fn is recommended)
...

NOTES:
- All Component screens *must* have initial state
- All Component screens *must* have a query
- All Component screens *must* have state that the ident-fn can use to generate a proper ident from your ident generator.
sourceraw docstring

dynamic-route-keyclj/s

source

DynamicRouterclj/s≠

clj
cljs
(DynamicRouter)
source

get-dynamic-router-queryclj/s

(get-dynamic-router-query router-id)

Get the query for the router with the given router-id.

Get the query for the router with the given router-id.
sourceraw docstring

get-dynamic-router-targetclj/smultimethod

Get the component that renders the given screen type. The parameter is simply the keyword of the module/component. Note that all have to match: the module name in the compiler that contains the code for the component, the first element of the ident returned by the component, and the keyword passed to this multimethod to retrieve the component.

Get the component that renders the given screen type. The parameter is simply the keyword of the module/component.
Note that all have to match: the module name in the compiler that contains the code for the component,
the first element of the ident returned by the component, and the keyword passed to this multimethod to retrieve
the component.
sourceraw docstring

install-route*clj/s

(install-route* state-map target-kw component)

Implementation of mutation. Useful for SSR setup.

Implementation of mutation. Useful for SSR setup.
sourceraw docstring

make-routeclj/s

(make-route name routing-instructions)

Make a route name that executes the provided routing instructions to change which screen in on the UI. routing-instructions must be a vector. Returns an item that can be passed to routing-tree to generate your overall application's routing plan.

(make-route :route/a [(router-instruction ...) ...])

Make a route name that executes the provided routing instructions to change which screen in on the UI. routing-instructions
must be a vector. Returns an item that can be passed to `routing-tree` to generate your overall application's routing
plan.

`(make-route :route/a [(router-instruction ...) ...])`

sourceraw docstring

route-to*clj/s

(route-to* state-map bidi-match)

Implementation of routing tree data manipulations on app state. Returns an updated app state.

WARNING: This function will not trigger dynamic module loading, as it is only responsible for returning a state-map that has been set (as far as is possible) to the given route. You typically do not want to use this on a client, but exists a separate function for server-side rendering to be easily able to route, since no dynamic code loading will be needed.

Implementation of routing tree data manipulations on app state. Returns an updated app state.

WARNING: This function will not trigger dynamic module loading, as it is
only responsible for returning a state-map that has been set (as far as is possible) to the given route. You typically
do *not* want to use this on a client, but exists a separate function for server-side rendering to be easily able
to route, since no dynamic code loading will be needed.
sourceraw docstring

route-to-impl!clj/s

(route-to-impl! {:keys [state reconciler] :as env} bidi-match)

Mutation implementation, for use as a composition into other mutations. This function can be used from within mutations. If a DynamicRouter is used in your routes, then this function may trigger code loading. Once the loading is complete (if any is needed), it will trigger the actual UI routing.

If routes are being loaded, then the root property in your app state :fulcro.client.routing/pending-route will be your bidi-match. You can use a link query to pull this into your UI to show some kind of indicator.

NOTE: this function updates application state and must not be used from within a swap on that state.

Mutation implementation, for use as a composition into other mutations. This function can be used
from within mutations. If a DynamicRouter is used in your routes, then this function may trigger
code loading. Once the loading is complete (if any is needed), it will trigger the actual UI routing.

If routes are being loaded, then the root property in your app state :fulcro.client.routing/pending-route
will be your `bidi-match`. You can use a link query to pull this into your UI to show some kind of indicator.

NOTE: this function updates application state and *must not* be used from within a swap on that state.
sourceraw docstring

router-instructionclj/s

(router-instruction router-id target-screen-ident)

Return the definition of a change-route instruction.

Return the definition of a change-route instruction.
sourceraw docstring

routers-tableclj/s

source

routing-treeclj/s

(routing-tree & routes)

Generate initial state for your application's routing tree. The return value of this should be merged into your overall app state in your Root UI component

(defui Root
  static prim/InitialAppState
  (initial-state [cls params]  (merge {:child-key (prim/get-initial-state Child)}
                                      (routing-tree
                                        (make-route :route/a [(router-instruction ...)])
                                        ...)))
  ...
Generate initial state for your application's routing tree. The return value of this should be merged into your overall
app state in your Root UI component

```
(defui Root
  static prim/InitialAppState
  (initial-state [cls params]  (merge {:child-key (prim/get-initial-state Child)}
                                      (routing-tree
                                        (make-route :route/a [(router-instruction ...)])
                                        ...)))
  ...
```
sourceraw docstring

routing-tree-keyclj/s

source

set-ident-route-paramsclj/s

(set-ident-route-params ident route-params)

Replace any keywords of the form :params/X with the value of (get route-params :X) in the given ident. By default the value of the parameter (which comes in as a string) will be converted to an int if it is all digits, and will be converted to a keyword if it is all letters. If you want to customize the coercion, just:

(defmethod r/coerce-param :param/NAME [k v] (transform-it v))
Replace any keywords of the form :params/X with the value of (get route-params :X) in the given ident. By default the value
of the parameter (which comes in as a string) will be converted to an int if it is all digits, and will be
converted to a keyword if it is all letters. If you want to customize the coercion, just:

```
(defmethod r/coerce-param :param/NAME [k v] (transform-it v))
```
sourceraw docstring

set-routeclj/s

source

set-route*clj/s

(set-route* state-map router-id screen-ident)

Set the given screen-ident as the current route on the router with the given ID. Returns a new application state map.

Set the given screen-ident as the current route on the router with the given ID. Returns a new application
state map.
sourceraw docstring

ui-dynamic-routerclj/s

(ui-dynamic-router props)
source

(update-routing-links state-map {:keys [handler route-params]})

Given the app state map, returns a new map that has the routing graph links updated for the given route/params as a bidi match.

This function should only be used if you only use static UI routing.

If you use DynamicRouter then you must use route-to-impl! instead.

Given the app state map, returns a new map that has the routing graph links updated for the given route/params
as a bidi match.

***This function should only be used if you only use static UI routing.***

If you use DynamicRouter then you must use `route-to-impl!` instead.
sourceraw docstring

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

× close