Fork me on GitHub
#beginners
<
2017-07-25
>
bones06:07:23

Anyone know of good reads when it comes to naming stuff? Specifically defining function args?

bones06:07:11

e.g. def point [x y] vs def point [[x y]]

bones06:07:31

readability vs conciseness vs expressivity

joshkh07:07:02

for the life of me i can't figure out how to construct a basic dropdown using this cljs ant-design react wrapper: https://github.com/priornix/antizer

joshkh07:07:51

(defn menu []
  (fn []
    [ant/menu
     [ant/menu-item "one"]
     [ant/menu-item "two"]
     [ant/menu-item "three"]]))

(defn dd [] [ant/dropdown [menu]]) ; No dice
(defn dd [] [ant/dropdown {:overlay [menu]}]) ; Nuh uh
(defn dd [] [ant/dropdown {:overlay menu}]) ; I didn't think this would work regardless, but nope!

foamdino11:07:56

I know I'm just being dumb here, but why is this wrong...

foamdino11:07:40

(->> parsed (:content) (-> (nth 3)))

foamdino11:07:16

the thread-first isn't pushing the result of (:content) as the first param to nth

foamdino11:07:50

the fact that nth order of args is different from (first) or (second)

dominicm11:07:50

@foamdino ^^ this is what that expands to 🙂

dominicm11:07:09

Fortunately, you can just use (->) all the way down

foamdino11:07:35

^^ swap (->> for (->

dominicm11:07:30

@foamdino macroexpand helps a lot with ->>

foamdino11:07:54

I'll have to remember that

foamdino11:07:20

I've had (-> to nested (->> before and it worked fine

dominicm11:07:18

Maybe the other way round?

(-> 10
    (->> (+ 4)))
is fine

dominicm11:07:07

The key thing is that ->> puts the argument at the end, so you were expanding with the result at the end (-> (nth 3) +it-went-here+)

dominicm11:07:27

What you wanted was (-> +it-went-here+ (nth 3))

foamdino11:07:06

yeah I expected that within the context of the thread-first it would put the argument in the correct place

gmercer12:07:16

@joshkh from the examples all of the components seem to be functions i.e.

(ant/menu 
        (ant/menu-item "one") 
        (ant/menu-item "two"))

gmercer12:07:16

whoops you are using reagent !!

joshkh12:07:16

ah yes, forgot to mention that part 🙂

gmercer12:07:26

@joshkh maybe lose the lambda in menu

(defn menu [] [ant/menu [ant/menu-item "one"] [ant/menu-item "two"] [ant/menu-item "three"]]) (defn dd [] [ant/dropdown {:overlay menu}]) `

joshkh12:07:18

it looks like the only difference between that and my third example is that the menu component is form1

joshkh12:07:47

okay let me give it a shot

joshkh12:07:41

nope, same error: antd.inc.js:32809 Uncaught TypeError: Cannot read property 'props' of undefined

gmercer14:07:28

@joshkh This works

(defn menu []
   [ant/menu {:mode "vertical" :theme "dark" :style {:height "100%"}}
    [ant/menu-item "one"]
    [ant/menu-item "two"]
    [ant/menu-item "three"]])
 
 (defn dd [] [ant/dropdown {:overlay (r/as-element (menu))} [:a {:className "ant-dropdown-link" :href "#"} [:span "Choose me!"]]])

gmercer14:07:43

(r/as-element (menu)) being the core change

gmercer14:07:42

and possibly also setting a :mode on the menu - that is from debugging memory

joshkh14:07:58

thanks, @gmercer ! one small change i had to make - (reagent/as-element [menu]) rather than (menu) (... might be a rum thing). the dropdowns don't close though after being selected. weird. but that solves the reagent problem, thanks!

dominicm16:07:12

@joshkh I think you're mixing reagent and ŝablono here. That might be why you're having issues.

dominicm16:07:43

Unless you're explicitly using them together. Then you can ignore me 🙂

josh_tackett22:07:07

Hey what is the lighttable plug in for paran shortcuts?