(format-query-string params)
Given a map of params, returns the query string to be appended on the path.
Given a map of params, returns the query string to be appended on the path.
(get-query-string route)
Given a path, returns the query string when one is present.
Given a path, returns the query string when one is present.
(hash->path token)
Given a hash in the format "#!/xxx" returns the path "/xxx"
Given a hash in the format "#!/xxx" returns the path "/xxx"
(hash-router navigate-callback)
Given a callback to be called with the event on Navigate returns a History instance. You can then use (.setToken (hash-router callback)) to change the hash. Changing the hash will trigger the navigate-callback. Docs: https://google.github.io/closure-library/api/goog.history.Event.html
Given a callback to be called with the event on Navigate returns a History instance. You can then use (.setToken (hash-router callback)) to change the hash. Changing the hash will trigger the navigate-callback. Docs: https://google.github.io/closure-library/api/goog.history.Event.html
(navigate! router bidi-routes route-name)
(navigate! router bidi-routes route-name params)
(navigate! router bidi-routes route-name params error-callback)
Given a router, bidi-routes, route-name and optional params and optional
error-callback, navigate to a route when possible. Navigate to empty hash
otherwise, or if provided a callback navigate to the return value of the
callback function. Check the route->path function docs about the callback
arguments. E.g.: (go! app-route :sample {:id 6})
Given a router, bidi-routes, route-name and optional params and optional error-callback, navigate to a route when possible. Navigate to empty hash otherwise, or if provided a callback navigate to the return value of the callback function. Check the route->path function docs about the callback arguments. E.g.: `(go! app-route :sample {:id 6})`
(navigate-event->token event)
Given a navigate event (goog.History/EventType.NAVIGATE) returns the hash
token without the #
. E.g.: if the route is
"http://exemple.com/#!/profile" when the event is triggered it will return
"!/profile"
Given a navigate event (goog.History/EventType.NAVIGATE) returns the hash token without the `#`. E.g.: if the route is "http://exemple.com/#!/profile" when the event is triggered it will return "!/profile"
(parse-query-string query-string)
Given a query string returns a map of params.
Given a query string returns a map of params.
(path->hash path)
Given a path "/xxx" retuns a hash to be used in links "#!/xxx"
Given a path "/xxx" retuns a hash to be used in links "#!/xxx"
(path->route bidi-routes path)
Given a path "/foo" returns the matched route or nil.
Given a path "/foo" returns the matched route or nil.
(path->token path)
Given a path "/xxx" retuns a token to be used by .setToken "!/xxx"
Given a path "/xxx" retuns a token to be used by .setToken "!/xxx"
(path-for route handler)
(path-for route handler params)
Given a route definition data structure, a handler and an params map, return a path that would route to the handler. The map must contain the values to any parameters required to create the path, and extra values are silently ignored. It's like bidi/path-for but with an map as params argument instead of key value pairs. It also adds a query-string when there is a :query-params key inside params.
Given a route definition data structure, a handler and an params map, return a path that would route to the handler. The map must contain the values to any parameters required to create the path, and extra values are silently ignored. It's like bidi/path-for but with an map as params argument instead of key value pairs. It also adds a query-string when there is a :query-params key inside params.
(route->path bidi-routes route-name)
(route->path bidi-routes route-name params)
(route->path bidi-routes route-name params error-callback)
Given bidi-routes, route-name and optional parameters and optional error-callback, creates a link to the route-name when possible. Create a link to empty hash otherwise. E.g.: (route->path [[["/sample/" [long :id]]] :sample] :sample {:id 5}) returns "/sample/5" The default error-callback is called with a map containing a key args with the route-name and params and a key error with the expection and prints the map and returns "#!/"
Given bidi-routes, route-name and optional parameters and optional error-callback, creates a link to the route-name when possible. Create a link to empty hash otherwise. E.g.: (route->path [[["/sample/" [long :id]]] :sample] :sample {:id 5}) returns "/sample/5" The default error-callback is called with a map containing a key args with the route-name and params and a key error with the expection and prints the map and returns "#!/"
(setup-router bidi-routes f)
(setup-router bidi-routes f f-error)
Given bidi-routes, f and optional f-error add a listener to update routes. When the route change, if the route matches f is called with a vector of [path parsed-route], else f-error is called on the current path, returns the router.
Given bidi-routes, f and optional f-error add a listener to update routes. When the route change, if the route matches f is called with a vector of [path parsed-route], else f-error is called on the current path, returns the router.
(sync-from-atom router path-atom)
Given a router and a atom containing the current path setups a watch that will update the hash when the atom content changes to a different path.
Given a router and a atom containing the current path setups a watch that will update the hash when the atom content changes to a different path.
(token->path token)
Given a token in the format "!/xxx" returns the path "/xxx"
Given a token in the format "!/xxx" returns the path "/xxx"
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close