Fork me on GitHub
#clojurescript
<
2017-04-15
>
lsenta02:04:08

Hi #clojurescript, I got a /my_file.js is not a relative path when I compile a project using the :libs and a goog-ready piece of javascript.

lsenta02:04:56

Is that the right place to ask? How can I debug this?

emccue02:04:18

On a Mac /path always refers to the root

emccue02:04:26

Try ./path

emccue02:04:46

Where . Will always resolve to the current directory

emccue02:04:22

Hence "/myfile.js" is not a relative path

emccue02:04:49

It is looking for a file named myfile.js at the root of the filesystem

lsenta02:04:55

:compiler {:libs ["./src/js"] ...} produces the same error

lauri05:04:09

Which version of clojurescript is being used and how are you compiling the project? Quick googling returned this: https://github.com/bhauman/lein-figwheel/issues/516

lsenta02:04:21

I use "src/js" usually

qqq05:04:00

is there a shorhand for

#?(:cljs
  (defn ... ))
I ask this as I have etags which search for ^(def which, unfortunately, won't find such indented functions

noisesmith05:04:10

@qqq this works for me

--exclude=.git                                                                  
--exclude=.svn                                                                  
--exclude=resources/*                                                           
--exclude=*/resources/*                                                         
--exclude=*/public/*                                                            
--exclude=.repl/*                                                               
--exclude=*/.repl/*                                                             
--exclude=out/*                                                                 
--exclude=*/out/*                                                               
--exclude=target/*                                                              
--exclude=*/target/*                                                            
--exclude=*min.js                                                               
--langdef=Clojure                                                               
--langmap=Clojure:.clj.cljc.cljs                                                
--regex-clojure=/\([ \t]*create-ns[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/n,namespace/
--regex-clojure=/\([ \t]*defn[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/f,function/
--regex-clojure=/\([ \t]*defn-[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/p,private function/
--regex-clojure=/\([ \t]*defmacro[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/m,macro/
--regex-clojure=/\([ \t]*definline[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/i,inline/
--regex-clojure=/\([ \t]*defmulti[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/a,multimethod definition/
--regex-clojure=/\([ \t]*defmethod[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/b,multimethod instance/
--regex-clojure=/\([ \t]*defonce[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/c,definition (once)/
--regex-clojure=/\([ \t]*defstruct[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/s,struct/
--regex-clojure=/\([ \t]*intern[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/v,intern/
--regex-clojure=/\([ \t]*ns[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/n,namespace/
--regex-clojure=/\([ \t]*def[ \t]+(\^:[^\t ]+)*[ \t]*([^0-9:#@][^ \t\[{(]+)/\2/d,definition/

qqq05:04:36

@noisesmith : lol, you win

noisesmith05:04:42

oh, that's a ctags config (exuberant ctags)

qqq05:04:07

the extend we as humans go to use regexp for properties context-free-grammrs would be much better fit

noisesmith05:04:46

I started with a gist someone shared, but it didn't work if a definition was type hinted or had other metadata, so I messed with it a bit, and also cleaned it up

Pablo Fernandez10:04:29

Is there any library that provides a ClojureScript debouncer? all I find are snippets on gists.

Pablo Fernandez11:04:38

Oh... interesting.

jimmy11:04:21

@pupeno You can find pretty much most of the things you need for everyday included in Google Closure 馃槃

pesterhazy11:04:14

馃憤 for closure

pesterhazy11:04:37

debouncer is also trivial to implement yourself

Pablo Fernandez11:04:25

@pesterhazy the fact that various issues were found on this code: https://gist.github.com/swannodette/5888989 and if you start following links shows discussion and different versions says to me that it's not so trivial.

pesterhazy11:04:42

haha good point, I spoke too soon

jonpither14:04:11

Hi. I am interopting with some JS (using child_process). I'm using async callbacks for notification of events happening, but I want to block until some condition is met. I don't quite want to pull in core.async, and ClojureScript doesn't have promises... wondering what the typical way to block in ClojureScript is without these tools?

noisesmith14:04:46

can't you use the Promise api via interop?

jonpither14:04:45

thanks @noisesmith will have a go

theasp14:04:42

I am getting java.net.SocketException: Protocol family unavailable when using figwheel, am I missing something totally obvious?

phill15:04:41

@theasp a few minutes ago I followed the guide at https://github.com/bhauman/lein-figwheel/wiki/Node.js-development-with-figwheel and it seems to be working as advertised

jonpither16:04:10

@noisesmith I don't think the Promise api helps me, seems in JS there's way to block synchronously from async code. Fundamental law of nature type thing... thanks though.

noisesmith16:04:03

this is what Promises are for though - they let you say "as soon as this thing has a value / success, run this code"

noisesmith16:04:20

it's not as elegant as core.async - which never blocks by the way if used correctly

noisesmith16:04:29

it just lets you write code that looks like it's blocking

jonpither16:04:33

fair enough.

noisesmith16:04:26

as I understand it your options come down to callbacks, promises, and core.async, in order of niceness of api

anmonteiro16:04:12

@jonpither child_process also has sync functions, can't you use those?

pesterhazy17:04:53

something cool for lumo would be to basically block the readline prompt until some event occurs

pesterhazy17:04:25

not sure how the API would look like...

pesterhazy17:04:09

(do (.setTimeout #(lumo.repl/unblock) 2000) (lumo.repl/block))

pesterhazy17:04:07

(let [p (lumo.repl/promise)] (.setTimeout js/window #(lumo.repl/deliver p 1234) (lumo.repl/deref p))

pesterhazy17:04:18

lumo.repl/deref would pause the repl's readline (not show the prompt) until the promise is delivered

dottedmag17:04:37

How does the third clause in https://github.com/clojure/clojurescript/blob/r1.9.521/src/main/cljs/cljs/core.cljs#L2464 work? It looks like it calls itself with the same arguments.

anmonteiro17:04:45

@dottedmag the function passed to reduce, in this case + itself, is called with 2 arguments

anmonteiro17:04:54

so it defers to the 2-arity version

dottedmag17:04:58

@anmonteiro I meant third clause (two arguments), not fourth.

anmonteiro17:04:45

so cljs.core/+ is a macro

anmonteiro17:04:55

ClojureScript can have macros & functions with the same name

anmonteiro17:04:00

this is normally used for inlining

jonpither17:04:31

Hi @anmonteiro thanks. I knew of sync.. Ive just found a different way of approaching the problem for now.

bhauman18:04:17

@jonpither look at goog.async.Promise and goog.async.Deferred in google closure

pesterhazy18:04:41

Now I feel left behind....

martinklepsch18:04:40

Hah, now I remember that there also was goog.functions.debounce :thinking_face:

martinklepsch18:04:18

Well, the more the better 馃槃

pesterhazy18:04:10

@pupeno why are you using import rather than require?

(require '[goog.functions])
(goog.functions.debounce f)

Pablo Fernandez18:04:38

No particular reason to be honest.

pesterhazy18:04:52

relatedly is there a guide to importing/requiring in clojurescript, especially when it comes to GCL?

pesterhazy18:04:07

I always have to guess how to import GCL functions

martinklepsch18:04:12

Another thing to write about 馃槃

Oliver George22:04:38

@U050TNB9F sometimes I'm damned if I can satisfy cursive. Code works but errors indicate unresolved symbols. Never sure if me or Collin is at fault... surely it's me :-)

pesterhazy18:04:35

thanks you two for writing up your findings

Pablo Fernandez18:04:35

@pesterhazy I updated it to use require instead of import. Looks cleaner. Thank you: https://pupeno.com/2017/04/15/clojurescript-debouncer/