Fork me on GitHub
#clojurescript
<
2016-12-10
>
samueldev00:12:25

hmm running into one of those situations where the error isn’t helpful 😞 https://puu.sh/sK5Hh/1491ba3a13.png

samueldev00:12:46

has anyone seen that before? whereabouts should I be looking for my error? (ns declaration & all requires seem fine…)

samueldev00:12:16

huh? (:require […])?

darwin00:12:41

sorry, try to comment out individual require pieces in that ns form

darwin00:12:53

by bisecting you could find the exact problem

darwin00:12:20

or point us to full source for that ns form

samueldev00:12:56

wait, can I not :refer :all in cljs?

darwin00:12:57

:refer :all is not a thing I guess

samueldev00:12:29

that makes sense I guess

darwin00:12:32

the error message means that it wants to treat :all as sequence

aengelberg03:12:20

What is the runtime complexity of ClojureScript's subs?

aengelberg03:12:25

This might be more of a JavaScript question.

kzeidler06:12:07

I have a basic cljs application template that loads reagent over boot. I'm trying to configure the cljs-repl. I've successfully gotten the browser to connect, but when I evaluate (+ 3 3) it gives java.lang.RuntimeException: Unable to resolve symbol: + in this context,

kzeidler06:12:32

What else do I need to do to load Clojurescript and my app's namespace?

martinklepsch07:12:55

@kzeidler did you run start-repl in the repl?

martinklepsch07:12:21

@kzeidler i.e. are you seeing something like cljs.user in front of the repl?

kzeidler07:12:59

@martinklepsch yes, with various flags passed while trying to spot my error. I now have a repl that loads the boot.user namespace, but seems to have a problem loading the namespace containing my app

kzeidler07:12:29

Error that I get when calling load-file on it: clojure.lang.Compiler$CompilerException: java.lang.IllegalAccessError: atom does not exist, compiling:(/Users/kevinzeidler/rhizome/berbert/src/cljs

kzeidler07:12:16

I take it that it's having trouble loading the Reagent dependency (it's :refer-ing to atom as the first argument to ns in that file)

martinklepsch07:12:11

@kzeidler just to be double clear, try the following: - start the build with boot dev - create a repl client with boot repl --client in another terminal - in that terminal run (start-repl) - reload browser if necessary - then you should see cljs.user=> or similar

kzeidler07:12:45

I'll try again from terminal, maybe my error has something to do with Cursive

kzeidler07:12:38

I did see those docs, but I'm unsure if the project skeleton requires those modifications to boot the repl. Does it?

martinklepsch07:12:38

you said you tried (start-repl) with various flags but it doesn't have any flags so I'm not sure what you're referring to...

kzeidler07:12:04

Sorry, *cljs-repl

martinklepsch07:12:10

the project skeleton is setup so you you should not need to make any further modifications

kzeidler07:12:03

martinklepsch: running via terminal with your instructions worked like a charm. Thanks!

martinklepsch07:12:40

@kzeidler I think the step you missed is calling (start-repl) once you're in a repl in the boot.user namespace

kzeidler07:12:13

For reference, which of those instructions does the nrepl connection step for Cursive override? Do I still need to call start-repl?

martinklepsch07:12:23

also you may want to pass a port to the cljs-repl task so that you can connect to the same port every time with cursive: https://github.com/adzerk-oss/boot-cljs-repl#cursive

martinklepsch07:12:07

@kzeidler what cursive does (guessing but seems likely) is basically boot repl --client so that's the step that's replaced

martinklepsch07:12:19

(start-repl) is really the most critical step 😉

kzeidler07:12:02

martinklepsh: I think possibly one of my problems earlier is that I read those docs, and added cljs-repl to (build) not realizing it was in run

kzeidler07:12:31

martinklepsch: this is too cool. basically the cljs reloadable config I was dreaming about, but couldn't quite configure on my own. thanks so much for providing it

martinklepsch07:12:56

@kzeidler realized that there's also this in the tenzing readme: https://github.com/martinklepsch/tenzing#connecting-to-the-browser-repl — did you see that?

martinklepsch07:12:24

@kzeidler you're welcome 🙂

kzeidler07:12:34

I did. This very likely is a Cursive issue, the instructions worked great when I entered them in the terminal

kzeidler07:12:57

(I have seen tickets on the Cursive github that suggest it's not fully compatible with boot, although some people insist it's possible with some workarounds)

martinklepsch07:12:48

Ok. Dunno if Cursive allows you to just connect to an nrepl port without anything else but if so it should work pretty much the same

kzeidler07:12:35

martinklepsch: sorry, one small bump I'm still trying to hammer out: the build pipeline sets up a watch already that recompiles the origin file if any changes are made. The nrepl doesn't appear to reload those definitions, at least right out of the box. Is it possible to configure the repl to do so?

martinklepsch08:12:24

@kzeidler are you talking about changes to clojure files or to clojurescript files?

cfleming10:12:22

@kzeidler Not much time sorry, packing for a flight, but you can connect to an nREPL port with Cursive using a Remote REPL config.

cfleming10:12:43

So you can run boot in the terminal, and then connect to localhost and the port it’s using.

cfleming10:12:27

That’s probably the easiest way to get started.

cfleming10:12:49

If you’re still having problems, ask in #cursive, or drop me a mail on <mailto:[email protected]|[email protected]>

cfleming10:12:05

I’m in and out of contact over the next couple of days though.

crankyadmin10:12:50

(defn jsonp [uri & opts]
  (let [{:keys [on-success on-timeout content callback-name callback-value timeout-ms]} opts
        req (goog.net.Jsonp. uri callback-name)
        data (when content (clj->js content))
        on-success (when on-success #(on-success (js->clj % :keywordize-keys true)))
        on-timeout (when on-timeout #(on-timeout (js->clj % :keywordize-keys true)))]
    (when timeout-ms (.setRequestTimeout req timeout-ms))
    (.send req data on-success on-timeout callback-value)))

(jsonp ""
       {:callback-value “callback"
        :on-timeout(fn [result] (js/console.log "Call timeout"))
        :on-success (fn [result] (js/console.log "This is a callback function for successful requests”))})

crankyadmin10:12:08

Uncaught ReferenceError: callback is not defined
    at spot.js:1
(anonymous) @ spot.js:1
😞

crankyadmin10:12:26

How does one go about getting JSONP in clojurescript?

crankyadmin10:12:40

var callback = function(result){console.log(result);}; in the console and calling the function from the cljs repl works…

crankyadmin10:12:11

So… How do I get it working in CLJS?

thheller11:12:05

@crankyadmin everything is namespaced in cljs

thheller11:12:43

(defn ^:export callback [result] ...)

thheller11:12:35

the name is then ns + callback

thheller11:12:41

so my.ns.callback

thheller11:12:51

the ^:export is important for :advanced

thheller11:12:33

but doesn't JsonP cover this for you?

crankyadmin11:12:01

My problem is that Amazon always return the callback as callback regardless of whether I use "

thheller11:12:03

why do you need the name at all?

thheller11:12:44

(.send req data on-success on-timeout) the name param is optional?

thheller11:12:38

ah amazon doesn't let you override it

crankyadmin11:12:42

Doesn’t work without it either… I was clutching at straws hoping for the best.

crankyadmin11:12:52

> ah amazon doesn't let you override it 😄

crankyadmin11:12:36

I suspect I’m going to have to do something nasty to make it work 😐

thheller11:12:00

weird they wouldn't let you override it

thheller11:12:31

you can just (js/goog.object.set js/window "callback" (fn [result] ....))

crankyadmin11:12:52

I deal with AWS day in day out… for seven years… this is probably the least weird thing I’ve ever seen them do. Sweet, I’ll try that once I’ve grabbed a coffee!

crankyadmin11:12:37

@thheller That worked. Cheers bud!

tobiash11:12:41

is there something like a partial-first? So that ((partial f b c) a)equals (f a b c)?

tobiash11:12:09

so there's no built-in for this? I was asking because threading has both flavours

thheller12:12:24

not that I'm aware of no

thheller12:12:50

don't think it is likely to exist since partial creates a function that accepts more than one extra arg

thheller12:12:15

that would be weird for partial-first

martinklepsch17:12:51

@dnolen wohooo, interesting 👍

dnolen17:12:32

@martinklepsch yeah big deal when you need to integrate random libs quickly

martinklepsch17:12:01

I guess the warnings show up in :none as well?

dnolen17:12:09

everything works in :none

dnolen17:12:19

also all the effort taken to make good externs isn’t gone to waste

dnolen17:12:29

not totally finished yet, but we use return type information

dnolen17:12:35

to keep propagating inference

martinklepsch17:12:43

gotta sleep but will give this a spin tomorrow!

richiardiandrea18:12:28

this is huge 😉

martinklepsch18:12:10

Essentially this would mean if I define constructors with the type hint on the returned value I would not need to worry about externs anymore, do I understand that right?

richiardiandrea18:12:15

@martinklepsch yes this is my understanding as well

martinklepsch18:12:17

Very very cool

dnolen19:12:32

@martinklepsch well as long as the thing returned also has an extern of course

dnolen19:12:53

people should play around with it and give feedback

dnolen19:12:32

there is some leeway here for ^js to trigger always generating externs even after fn/methods invokes

dnolen19:12:57

but need to careful here - repercussion for dead code elimination if you go that far

gowder22:12:15

For some reason I want to wonder if spec can get involved with this awesomeness as a substitute for type hints?