Fork me on GitHub
#clojurescript
<
2016-05-16
>
abdullahibra10:05:22

how can i insert <div class="more"></div> tag after <div class="foo"> tag using google closure?

rauh10:05:15

in particular: goog.dom.insertSiblingAfter

koolkat12:05:14

@mccraigmccraig: Thank you very much for the link now i know exactly what happens.

bwstearns12:05:16

@mikethompson: interesting. I thought that was odd but a lot of the answers on stack/in tutorials seem to be ok with that particular shadowing, I took it for idiomatic.

bwstearns13:05:46

@darwin: good call on some?

bwstearns13:05:12

@mikethompson: Oh. damn. I just read 2 properly (most of the way through coffee… took me a minute). That would absolutely be the cause lol.

iwankaramazow18:05:52

I just noticed a conversation on Twitter about project setup complexity with nrepl. David Nolen commented that inferior lisp style communication works just fine. I'm pretty new to Lisp in general, what's inferior lisp style communication ?

dnolen18:05:56

@iwankaramazow: Emacs has a simple stdin/out based Lisp REPL integration mode - inferior-lisp

dnolen18:05:26

it’s called that in contrast historically to SLIME - https://common-lisp.net/project/slime/

dnolen18:05:22

but of course there’s nothing specific about Lisp here - many REPL integrations with various languages can work in the exact same way as inferior lisp

dnolen18:05:28

and they do

iwankaramazow18:05:54

Thanks for the response!

dimiter19:05:20

Hey all, given the following array of maps, what is the easiest way to get the label for a given value

(def als
  [{:label "Guest" :value 10}
   {:label "Reporter" :value 20}
   {:label "Developer" :value 30}
   {:label "Master" :value 40}
   {:label "Owner" :value 50}])

jr19:05:02

(:label (first (filter …))) is easiest given that structure

jr19:05:12

you can manipulate it to be a value -> label lookup though

jr19:05:16

user=> (into {} (map (juxt :value :label) als))
{10 "Guest", 20 "Reporter", 30 "Developer", 40 "Master", 50 "Owner”}

dimiter19:05:43

How can I access the label with an int key.

jr19:05:27

using get

jr19:05:30

user=> (get (into {} (map (juxt :value :label) als)) 10)
“Guest”

dimiter19:05:52

Perfect. Thanks.

jr19:05:21

maps implement IFn and can be called to lookup as well

jr19:05:36

({10 “Guest”} 10)
=> “Guest”

jwm19:05:16

clojure is so sick 🙂

jwm19:05:35

I think I have a little too much fun coding in it

noisesmith20:05:51

regarding @dimiter 's question, seems like you could simplify that with group-by

noisesmith20:05:37

maybe not that much simpler I guess

=> (:label (first (get (group-by :value als) 10)))
"Guest"

pataprogramming22:05:38

Any thoughts on approaches for charting with Reagent? I've got data flowing to the browser, and can display a dynamic table that will impress people who imprinted on amber-screen monitors at an early age. Now I need to impress everybody else.

pataprogramming22:05:39

After I get some charts established, I may be looking to do some fancy custom animated visualizations, as well, if that influences suggestions.

mvaline22:05:09

I have had a lot of success using d3 through cljsjs in reagent/re-frame @pataprogramming

pataprogramming22:05:12

Thanks, @mvaline...I figure it is finally time to sit down and read through the whole re-frame tutorial, now that I understand how the CLJ<->CLJS pipes slot together. 🙂

mvaline22:05:26

I definitely recommend it. PM me if you have questions, glad to help

pataprogramming22:05:49

Thanks...how deep on JS will I have to get? I have basically zero modern JS knowledge, and have been using CLJS to try to paper over as many things as possible.

pataprogramming22:05:37

I think that previously here, @fasiha mentioned using Reagent+re-frame+SVG to avoid interacting with d3, but I'm not sure what style of visualizations that is for.

mvaline22:05:46

if you are using an outside js library you will have to know the basics for sure

mvaline22:05:40

I think any way you go you will have to have a decent grasp of JS on an app of medium/large size

mvaline22:05:21

the nice thing is that calling JS from CLJS imo is really easy and also unnecessary 90% of the time

pataprogramming22:05:12

That's fair. I'm in proof-of-concept mode at the moment, so the front-end will need to be built up from scratch again at some point in the future. My main goal is to make progress as rapidly as possible with things that look nifty, without slowing down my coding pace more than is necessary.

pataprogramming22:05:33

Of course, sorting out the CLJS tooling on its own took a week. 😕 But it's pretty darned cool now that it's working.

dimiter22:05:23

Anyone have an idea of what I should define for externs if I want to use a library like this?

dimiter22:05:39

Or is there a generator?

dimiter23:05:35

Interesting “bug” in advanced compile mode. The following does not work, the avatar URL never gets loaded.

(defn render-option [option]
  (html [:div.dropdown-menu-user
          [:img.avatar {:src (.-avatar_url option) :width 20}]
          [:strong.dropdown-menu-user-full-name (.-name option)]
          [:span.dropdown-menu-user-username
           (str (.-username option) " " (.-email option))]]))
The following works.
(defn render-option [option]
  (html [:div.dropdown-menu-user
         [:img.avatar {:src (aget option "avatar_url") :width 20}]
         [:strong.dropdown-menu-user-full-name (.-name option)]
         [:span.dropdown-menu-user-username
          (str (.-username option) " " (.-email option))]]))