Fork me on GitHub
Ramon Rios11:04:00

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?


Those were not "yes/no" questions...

Ramon Rios12:04:39

I'm sorry. I edited the question to try make it more readable

Ramon Rios12:04:48

The "sub-vector" is the vector in the key :data and the "main data is the :customer and :police info


OK. What does it have to do with re-frame though?

Ramon Rios12:04:02

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]
           [: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)))))
    [] data))

Ramon Rios12:04:53

Thanks, i'll try that!

Quentin Le Guennec18:04:20

Hello, how do I lift a subscription into another subscription? Some kind of monad: • sub A • sub B depends on sub A

Thomas Karras18:04:11

somewhat buried but you can use a layer 3 subscription, an example is here,

Quentin Le Guennec18:04:39

@genothk that works, thanks a lot!


I need to create an event that creates multiple effects of the same type and therefore the same key (in this case I want it to dispatch multiple events), how do I do that?


There's a :dispatch-n effect, built into re-frame.


That might work, where are these built-in effects documented?


That works, thanks!