This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-01
Channels
- # announcements (21)
- # architecture (6)
- # aws (18)
- # babashka (14)
- # beginners (231)
- # boot (1)
- # calva (2)
- # chlorine-clover (22)
- # cider (34)
- # clara (16)
- # clj-kondo (53)
- # cljdoc (5)
- # cljs-dev (22)
- # cljsrn (3)
- # clojure (283)
- # clojure-europe (24)
- # clojure-italy (9)
- # clojure-nl (5)
- # clojure-spec (5)
- # clojure-uk (57)
- # clojurescript (14)
- # core-typed (8)
- # cursive (4)
- # data-science (7)
- # datomic (41)
- # docker (24)
- # duct (2)
- # emacs (2)
- # exercism (29)
- # fulcro (96)
- # graalvm (4)
- # jobs-discuss (1)
- # kaocha (53)
- # lambdaisland (20)
- # malli (5)
- # nrepl (4)
- # observability (7)
- # off-topic (40)
- # pathom (44)
- # pedestal (8)
- # re-frame (19)
- # shadow-cljs (58)
- # spacemacs (2)
- # sql (9)
- # tools-deps (15)
- # vim (3)
- # yada (10)
Hello everyone, each row that i receive cointains this type of data
{:customer-id "cid-1"
:customer "Customer 1"
:policy "Policy 1"
:data [{:type "Term" :bruto-nr 300
:brio-nr 100}
{:type "Settlement" :bruto-nr 300
:brio-nr 100}]
I'm trying to implement something similiar on the image: This vector in the key "main" show this data without repeating the customer and police data twice. Is that possible. I'm struggling a lot to do it.I have no idea what you mean. What "sub-vector" do you mean? What is the "main" data?
I'm sorry. I edited the question to try make it more readable
The "sub-vector" is the vector in the key :data
and the "main data is the :customer
and :police
info
I'm using re-frame datatable library.
For the purpose of the question, it doesn't matter. The only thing that it tells me is that you want to end up having Hiccup that represents that table. So it's a question about transforming the data that you have into Hiccup.
You need to reduce
over the main vector of maps with "main" data and accumulate the rows. Each "main" vector would create N rows where N is the number of items in the "sub-vector", as you call it.
Something like this. Didn't check.
(letfn [(mk-row [item sub-item]
[:tr
[:td (:customer item)]
[:td (:policy item)]
[:td (:type sub-item)]
[:td (:bruto-nr sub-item)]])]
(reduce (fn [acc datum]
(if (seq (:data datum))
(-> (conj acc (mk-row datum (first (:data datum))))
(into (map #(mk-row nil %) (rest (:data datum)))))
acc))
[] data))
Thanks, i'll try that!
Hello, how do I lift a subscription into another subscription? Some kind of monad: • sub A • sub B depends on sub A
somewhat buried but you can use a layer 3 subscription, an example is here, https://github.com/day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs
@genothk that works, thanks a lot!