Liking cljdoc? Tell your friends :D

tyrell.router

Simple router for ty web components using zipper-based tree structure

Simple router for ty web components using zipper-based tree structure
raw docstring

*permissions*cljs


*roles*cljs


*router*cljs


*user*cljs


authorized?cljs

(authorized? component-id)

Check if user can access component

Check if user can access component
raw docstring

clj->querycljs

(clj->query data)

Convert clojure map to URLSearchParams string

Convert clojure map to URLSearchParams string
raw docstring

component->locationcljs

(component->location tree id)

Find component by id in tree, return zipper location

Find component by id in tree, return zipper location
raw docstring

component-pathcljs

(component-path tree id)

Build URL path from root to component, including hash fragment if present

Build URL path from root to component, including hash fragment if present
raw docstring

component-tree-zippercljs

(component-tree-zipper root)

Returns routing tree zipper

Returns routing tree zipper
raw docstring

exact-match?cljs

(exact-match? tree current-url component-id)

Compare current URL with component path, including hash fragments. A route with a :hash needs that exact hash. A route without one also matches when the URL's hash isn't a route of its own: that hash is an in-page anchor (/components/select#api), not a different page.

Compare current URL with component path, including hash fragments.
A route with a :hash needs that exact hash. A route without one also
matches when the URL's hash isn't a route of its own: that hash is an
in-page anchor (/components/select#api), not a different page.
raw docstring

get-current-urlcljs

(get-current-url)

Get current full URL including hash

Get current full URL including hash
raw docstring

handle-landing!cljs

(handle-landing!)

Check if current location should trigger landing redirect. Always runs - redirects to best available route for 404s, auth failures and paths that only exist with a hash. Redirects replace the history entry, so Back doesn't bounce off the redirecting URL.

Check if current location should trigger landing redirect.
Always runs - redirects to best available route for 404s, auth failures
and paths that only exist with a hash. Redirects replace the history
entry, so Back doesn't bounce off the redirecting URL.
raw docstring

init!cljs

(init!)
(init! base)

Initialize router with browser events and smart landing redirects

Initialize router with browser events and smart landing redirects
raw docstring

landing-candidatescljs

(landing-candidates)

Get current landing candidates for debugging

Get current landing candidates for debugging
raw docstring

(link parent children)

Add component(s) to router tree under parent. Parent should be a component id. Children can be a single component map or a vector of component maps.

Add component(s) to router tree under parent.
Parent should be a component id.
Children can be a single component map or a vector of component maps.
raw docstring

maybe-add-basecljs

(maybe-add-base base url)

For given base and url will add base prefix if it exists to url. If base is nil than URL is returned

For given base and url will add base prefix
if it exists to url. If base is nil than URL
is returned
raw docstring

maybe-remove-basecljs

(maybe-remove-base base url)

For given base and url will return URL without base. If base is nil function will return URL immediately

For given base and url will return URL without
base. If base is nil function will return URL
immediately
raw docstring

(navigate! route-id)
(navigate! route-id params)

Navigate to a route by id with optional query params

Navigate to a route by id with optional query params
raw docstring

on-path?cljs

(on-path? tree path id)

For given path and component id function will get component path and check if given path starts with component path, at a segment boundary.

If it does, than component is on path (true)

For given path and component id function will get
component path and check if given path starts with
component path, at a segment boundary.

If it does, than component is on path (true)
raw docstring

parse-urlcljs

(parse-url url)

Parse URL into path and hash components

Parse URL into path and hash components
raw docstring

query->cljcljs

(query->clj qp)

Convert URLSearchParams to clojure map

Convert URLSearchParams to clojure map
raw docstring

query-paramscljs

(query-params)

Get current query parameters as a map

Get current query parameters as a map
raw docstring

redirect-targetcljs

(redirect-target tree url)

Route id the URL should be redirected to, or nil when it can stay.

  • A route matches exactly: stay.
  • The path has routes, but all of them carry a hash (/welcome with only #top and #event-booking): go to the best of those — highest :landing, then tree order — instead of rendering nothing.
  • No route is on the path at all: go to the best landing route.
  • Otherwise stay: a path below a route (/users/123) is how apps read dynamic segments with non-exact rendered?.
Route id the URL should be redirected to, or nil when it can stay.

- A route matches exactly: stay.
- The path has routes, but all of them carry a hash (/welcome with only
  #top and #event-booking): go to the best of those — highest :landing,
  then tree order — instead of rendering nothing.
- No route is on the path at all: go to the best landing route.
- Otherwise stay: a path below a route (/users/123) is how apps read
  dynamic segments with non-exact rendered?.
raw docstring

rendered?cljs

(rendered? component-id)
(rendered? component-id exact?)

Check if component is on current path

Check if component is on current path
raw docstring

set-componentcljs

(set-component tree {:keys [id parent] :as component})

Function used to add component to component tree. For given component tree add component by specifying component id and component parent.

Function used to add component to component tree.
For given component tree add component by specifying
component id and component parent.
raw docstring

set-query!cljs

(set-query! params)
(set-query! params action)

Set query parameters. Action can be :replace (default) or :push

Set query parameters. Action can be :replace (default) or :push
raw docstring

update-router-from-browser!cljs

(update-router-from-browser! base)

Update router state from current browser URL

Update router state from current browser URL
raw docstring

url->componentscljs

(url->components)
(url->components url)
(url->components tree url)

Returns all components that are rendered for given URL

Returns all components that are rendered for given URL
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close