(-replace-controller controllers controller)
(case-route f & pairs)
Reagent component that renders different components for different routes.
Semantics similar to clojure.core/case
You can include a single default component at the end that serves as the default view
Parameters:
f
: A function that receives the route data on every route change, and returns the value to dispatch on.
pairs
: A pair consists of the dispatch value and the reagent component to dispatch to. An optional single default
component can be added at the end.
Returns the first component with a matching dispatch value.
Usage:
[k/switch-route (fn [route] (:handler route))
:index [:div "This is index page"]
:about [:div "This is the about page"]
[:div "Probably also the index page"]]
Reagent component that renders different components for different routes. Semantics similar to clojure.core/case You can include a single default component at the end that serves as the default view Parameters: `f`: A function that receives the route data on every route change, and returns the value to dispatch on. `pairs`: A pair consists of the dispatch value and the reagent component to dispatch to. An optional single default component can be added at the end. Returns the first component with a matching dispatch value. Usage: ``` [k/switch-route (fn [route] (:handler route)) :index [:div "This is index page"] :about [:div "This is the about page"] [:div "Probably also the index page"]] ```
(extra-options options)
Complete listing of invalid options sent to the start!
function.
Complete listing of invalid options sent to the `start!` function.
(path-for handler & params)
Make a uri from route data. Useful for avoiding hard coded links in your app.
Parameters:
handler
: The reitit handler from route data
params
: Reitit route params for the requested route
Usage: [:a {:href (k/path-for [:orders :sort-by :date]} "Orders sorted by date"]
Make a uri from route data. Useful for avoiding hard coded links in your app. Parameters: `handler`: The reitit handler from route data `params`: Reitit route params for the requested route Usage: `[:a {:href (k/path-for [:orders :sort-by :date]} "Orders sorted by date"]`
(reg-controller id controller)
Put a controller config map into the global controller registry.
Parameters:
id
: Must be unique in controllere registry. Will appear in logs.
controller
: A map with the following keys:
:params
: A function that receives the route data and returns the part that should be sent to the start
function. A nil
return means that the controller should not run for this route.
:start
: A function or an event vector. Called when params
returns a non-nil value different from the previous
invocation. The function receives whatever non-nil value that was returned from params
,
and returns a re-frame event vector. If the function does nothing but returning the vector, the surrounding function
can be omitted.
:stop
: Optional. A function or an event vector. Called when previous invocation of params
returned non-nil and the
current invocation returned nil. If the function does nothing but returning the vector, the surrounding function
can be omitted.
Put a controller config map into the global controller registry. Parameters: `id`: Must be unique in controllere registry. Will appear in logs. `controller`: A map with the following keys: - `:params`: A function that receives the route data and returns the part that should be sent to the `start` function. A nil return means that the controller should not run for this route. - `:start`: A function or an event vector. Called when `params` returns a non-nil value different from the previous invocation. The function receives whatever non-nil value that was returned from `params`, and returns a re-frame event vector. If the function does nothing but returning the vector, the surrounding function can be omitted. - `:stop`: Optional. A function or an event vector. Called when previous invocation of `params` returned non-nil and the current invocation returned nil. If the function does nothing but returning the vector, the surrounding function can be omitted.
(start! options)
Starts your client application with the specified options
.
This function is intentionally forgiving in certain ways:
options
altogether. kee-frame chooses sensible defaults for you and leads the way.Usage:
(k/start! {:debug? true
:routes my-reitit-routes
:hash-routing? true
:initial-db {:some-property "default value"}
:root-component [my-reagent-root-component]
:app-db-spec :spec/my-db-spec})
Starts your client application with the specified `options`. This function is intentionally forgiving in certain ways: - You can call it as often as you want. Figwheel should call it on each code change - You can omit the `options` altogether. kee-frame chooses sensible defaults for you and leads the way. Usage: ``` (k/start! {:debug? true :routes my-reitit-routes :hash-routing? true :initial-db {:some-property "default value"} :root-component [my-reagent-root-component] :app-db-spec :spec/my-db-spec}) ```
(switch-route f & pairs)
DEPRECATED in favor of case-route
Reagent component that renders different components for different routes.
You might need to include a case for nil
, since there are no route data before the first navigation.
Parameters:
f
: A function that receives the route data on every route change, and returns the value to dispatch on.
pairs
: A pair consists of the dispatch value and the reagent component to dispatch to.
Returns the first component with a matching dispatch value.
Usage:
[k/switch-route (fn [route] (:handler route))
:index [:div "This is index page"]
:about [:div "This is the about page"]
nil [:div "Probably also the index page"]]
DEPRECATED in favor of case-route Reagent component that renders different components for different routes. You might need to include a case for `nil`, since there are no route data before the first navigation. Parameters: `f`: A function that receives the route data on every route change, and returns the value to dispatch on. `pairs`: A pair consists of the dispatch value and the reagent component to dispatch to. Returns the first component with a matching dispatch value. Usage: ``` [k/switch-route (fn [route] (:handler route)) :index [:div "This is index page"] :about [:div "This is the about page"] nil [:div "Probably also the index page"]] ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close