(keyify f xs & {:keys [key-fn] :or {key-fn default-key-fn}})
Given a function and collection will add unique :key
value
to metadata information
Customizable :key-fn
functionality for specifying list item :key
value
Use example:
(require '[ant-man.core :as ant-man]
'[ant-man.helpers :as ant-man-helpers]
'[reagent.core :as r])
(def selection (r/atom nil))
(def example-collection [{:label "foo" :id 1} {:label "bar" :id 2}])
;; Default
[ant-man/select {:on-change (fn [val] (reset! selection val))
:value @selection}
(ant-man-helpers/keyify
(fn [{:keys [label id]}]
[ant-man/select-option {:value id} label])
example-collection)]
;; Custom `:key-fn`
[ant-man/select {:on-change (fn [val] (reset! selection val))
:value @selection}
(ant-man-helpers/keyify
(fn [{:keys [label id]}]
[ant-man/select-option {:value id} label] :key-fn (fn [x] [(inc x)]))
example-collection)]
Given a function and collection will add unique `:key` value to metadata information Customizable `:key-fn` functionality for specifying list item `:key` value Use example: ``` (require '[ant-man.core :as ant-man] '[ant-man.helpers :as ant-man-helpers] '[reagent.core :as r]) (def selection (r/atom nil)) (def example-collection [{:label "foo" :id 1} {:label "bar" :id 2}]) ;; Default [ant-man/select {:on-change (fn [val] (reset! selection val)) :value @selection} (ant-man-helpers/keyify (fn [{:keys [label id]}] [ant-man/select-option {:value id} label]) example-collection)] ;; Custom `:key-fn` [ant-man/select {:on-change (fn [val] (reset! selection val)) :value @selection} (ant-man-helpers/keyify (fn [{:keys [label id]}] [ant-man/select-option {:value id} label] :key-fn (fn [x] [(inc x)])) example-collection)] ```
(read-key x)
Helper funtion that reads and parses meta information from keyify
Helper funtion that reads and parses meta information from `keyify`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close