Fork me on GitHub
#clojurescript
<
2020-08-25
>
rickmoynihan10:08:30

What is the difference between cljs-devtools and dirac-devtools?

rickmoynihan10:08:47

It seems dirac includes more functionality, integrates chrome repl with nrepl etc…

rickmoynihan10:08:16

Can you use dirac with shadow-cljs?

p-himik11:08:32

There's also #dirac

👍 3
darwin14:08:04

btw. dirac 1.6.0 added support for shadow-cljs REPL: https://github.com/binaryage/dirac/releases/tag/v1.6.0

🎉 3
Sam Ritchie14:08:16

Hey all - I have a few spots in sicmutils where I implement IFn, and override all 21 arities: https://github.com/littleredcomputer/sicmutils/blob/master/src/sicmutils/structure.cljc#L154 Is there a more straightforward, idiomatic way to do this, like Clojure's override of (applyTo [s xs] (AFn/applyToHelper s xs))

Sam Ritchie14:08:46

I could write a macro of course, but maybe there is something cleaner

dnolen15:08:50

@sritchie09 IFn etc in ClojureScript still need work, it's languished because it has considerably less utility due to ClojureScript fns being JavaScript fns

dnolen15:08:27

that is we don't dogfood it, and it's kind of a power feature and few patches 🙂

Sam Ritchie15:08:58

yes, makes sense for the usual case. here, we do things like make a tuple that acts like a juxt and a seq, so ((up inc square dec) 10) => (11 100 9) , etc

Sam Ritchie15:08:29

makes sense! @dnolen I definitely felt a little power coursing through the keyboard as I typed the final character of the 21st arity

dnolen15:08:55

if you look at JIRA you'll see there's some basic outstanding things missing

dnolen15:08:18

all of intermediate level difficulty

dnolen15:08:34

calls w/ more than 20 args need to be reshaped

dnolen15:08:52

internal fn dispatching probably needs to be fixed

dnolen15:08:58

then IFn can work

dnolen15:08:19

there's a bunch of tests now so wouldn't be surprised if you have to chase some issues w/ apply

dnolen15:08:57

so a surprising amount of work for something that's not used that often

dnolen15:08:04

because again regular fns don't need it

Sam Ritchie15:08:38

thanks for the heads up, as I start to test this more maybe this can be a first contribution area for cljs

Sam Ritchie15:08:30

I recently found a very minor fn typo in Lisp in Small Pieces and got myself on the errata list, so I'm feeling pretttty solid about my compiler hacking abilities

dnolen15:08:58

but in all seriousness patches here would be welcome

dnolen15:08:20

been in my queue for years but more pressing things to do

Sam Ritchie15:08:41

👍 yes, absolutely, if I find anything (even if not, I'll look for it) I'd be thrilled to contribute

jjttjj20:08:04

Trying to get vega-embed working in cljs/shadow.

...
(:require ["vega" :as v]
          ["vega-lite" :as vl]
          ["vega-embed" :as vegaEmbed])
...
(let [vspec (->> {
                  "$schema"     "https//vega.github.io/schema/vega-lite/v4.json",
                  "description" "A simple bar chart with embedded data.",
                  "data"        {
                                 "values" [
                                           {"a" "A", "b" 28}, {"a" "B", "b" 55}, {"a" "C", "b" 43},
                                           {"a" "D", "b" 91}, {"a" "E", "b" 81}, {"a" "F", "b" 53},
                                           {"a" "G", "b" 19}, {"a" "H", "b" 87}, {"a" "I", "b" 52}
                                           ]
                                 },
                  "mark"        "bar",
                  "encoding"    {
                                 "x" {"field" "a", "type" "nominal", "axis" {"labelAngle" 0}},
                                 "y" {"field" "b", "type" "quantitative"}
                                 }
                  }
                 clj->js)]
  (-> (vegaEmbed chart-div vspec (clj->js {:renderer "canvas"
                                          :mode     "vega-lite"
                                          :logLevel v/Debug}))
      (.then (fn [_]
               (log/info "DONE WITH VEGA")))
      (.catch (fn [e]
                (log/error "ERROR IN VEGA" e)))))
Is giving me
TypeError: this.globalCursor is not a function
and points to this line in vega: https://github.com/vega/vega/blob/1f93346f7f54591698c0eb7cf8978f49b25e84ec/packages/vega-view/src/View.js#L73 Anyone have any hints?

thheller22:08:24

@jjttjj just a guess but since it wants to use this maybe vegaEmbed. not vegaEmbed? hmm nevermind if it returns a promiseI guess not 😛

njj22:08:56

Whats the most "popular" web framework for clj/cljs these days?

phronmophobic22:08:36

probably #fulcro or #re-frame

👍 3
clumsyjedi23:08:50

Can anyone point me to the magic incantation to load a npm-deps like @angular/core? I'm actually trying to import @myorg/mylib and not having any luck. I can get react to work through. I'm trying @angular/core to verify that the mechanism works on a public library with an org/name but no joy. I've tried

:npm-deps {"react" "16.13.1"
           "@angular/core" "10.0.12"}
With and without the @ and also
(:require
   [react :as react]
   ["@angular/core" :as ass])
with and without the @ - any pointers?

athomasoriginal13:08:38

Have you tried using :target :bundle instead of :npm-deps and then try your require? :thinking_face: Example: https://clojurescript.org/guides/webpack

Oliver George23:08:39

I'm looking for a clever way to make my js/console.log display cleanly with and without cljs-devtools installed

Oliver George23:08:59

Feels like it should be possible by using something like this...

(defn console-logger
  [data]
  (binding [*print-level* 3 *print-length* 5]
    (js/console.log (with-meta (pr-str data) {:data data}))))

Oliver George23:08:19

if cljs-devtools is installed you can drill into metadata

Oliver George23:08:01

String form will work in all situations and not take too long to serialize

Oliver George23:08:22

Obvious problem is that string doesn't implement the metadata protocol

Oliver George23:08:06

I think the answer is something like: why not just specify! that protocol.

Oliver George23:08:12

No joy with this. I'm guessing cljs-devtools tests for string before falling back to fancy behaviour. Looks like specify! doesn't work on a string.

(defn log-data
  [data]
  (binding [*print-level* 3
            *print-length* 5]
    (js/console.log (specify! (pr-str data) IMeta (-meta [_] data))))))