Clojurians
#cljsrn
<
2016-01-30
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

potapenko04:01:27

@eploko:

(defn- create-list-view-ds 
  ([] (create-list-view-ds (fn[r1 r2] (not= r1 r2))))
  ([row-compare-fn]
   (let[DataSource (-> js/React .-ListView .-DataSource)]
     (DataSource. (clj->js {:rowHasChanged row-compare-fn})))
   )
  )

(defn- convert-to-array [vec]
  (let [arr #js[]]
    (doseq [x vec] (.push arr x))
    arr)
  )

(defn create-list-model 
  ([model row-compare-fn]
  (.cloneWithRows (create-list-view-ds row-compare-fn) (convert-to-array model)))
  ([model]
  (.cloneWithRows (create-list-view-ds) (convert-to-array model)))
  )
(defn render-row [row-data] 
   (r/as-element [my-row row-data]) 
  )

(defn my-list-view [list]
  (let[ds (utils/create-list-model list)]
    [list-view {:dataSource ds :renderRow render-row}])
  )

sveri09:01:19

Hi there, I just installed re-natal on W7 and when I run: re-natal init ToBuy I get this message: Leiningen is required ()which is weird as I have leiningen installed (2.5.2) and it is recognized by everything else I use. Do I need a certain path or environment variable set?

drapanjanas09:01:54

@sveri never tested it on windows so might be that something has to be changed to support it. Presense of lein is checked by executing type lein

sveri09:01:08

@drapanjanas: Ah ok, what is type in that context? I don't have it installed on windows

sveri09:01:31

Hm, running that one on cygwin says lein not found

sveri10:01:01

I think that makes sense as I dont have it installed in "cygwin" but only in windows, whatever the difference might be

donmullen15:01:28

@seantempesta: Nice article re: boot from seancorfield : https://seancorfield.github.io/blog/2016/01/29/rebooting-clojure/

eploko16:01:47

@potapenko, thanks! Now I have to find out what exactly is the difference between your code (that apparently works!) and mine. :simple_smile:

eploko16:01:53

Spotted it! Well, the first thing is the data source should be passed to the view as :dataSource and not as :data-source. The latter doesn’t work for whatever reason. As a side note, the render row method can both be passed as :render-row or :renderRow and it works both ways. Heh. Secondly, the render-row function should return a React component and not an array. The latter would be okay if the array was later rendered by reagent, but the listview doesn’t do any kind of post-processing on the data it gets from render-row and merely tries to return that to React, which bails if it’s a plain clojure array. Thanks a ton! :simple_smile: