Liking cljdoc? Tell your friends :D
ClojureScript only.

ant-man.helpers


keyifycljs

(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]
          [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/children
    (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/children
    (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]
          [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/children
    (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/children
    (fn [{:keys [label id]}]
      [ant-man/select-option {:value id} label] :key-fn (fn [x] [(inc x)]))
    example-collection)]
```
sourceraw docstring

read-keycljs

(read-key x)

Helper funtion that reads and parses meta information from keyify

Helper funtion that reads and parses meta information from `keyify`
sourceraw docstring

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

× close