This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-15
Channels
- # beginners (15)
- # boot (4)
- # cider (1)
- # cljsrn (16)
- # clojars (1)
- # clojure (92)
- # clojure-india (3)
- # clojure-russia (27)
- # clojure-spec (9)
- # clojure-uk (5)
- # clojurescript (73)
- # cursive (28)
- # datascript (10)
- # emacs (1)
- # events (5)
- # hoplon (1)
- # instaparse (7)
- # juxt (2)
- # klipse (13)
- # lumo (17)
- # off-topic (166)
- # onyx (4)
- # protorepl (5)
- # re-frame (5)
- # reagent (13)
- # rum (26)
- # untangled (17)
- # yada (3)
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.
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
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@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/
@noisesmith : lol, you win
oh, that's a ctags config (exuberant ctags)
the extend we as humans go to use regexp for properties context-free-grammrs would be much better fit
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
Is there any library that provides a ClojureScript debouncer? all I find are snippets on gists.
Oh... interesting.
@pupeno You can find pretty much most of the things you need for everyday included in Google Closure 馃槃
馃憤 for closure
debouncer is also trivial to implement yourself
@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.
haha good point, I spoke too soon
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?
can't you use the Promise api via interop?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
thanks @noisesmith will have a go
I am getting java.net.SocketException: Protocol family unavailable when using figwheel, am I missing something totally obvious?
@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
@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.
this is what Promises are for though - they let you say "as soon as this thing has a value / success, run this code"
it's not as elegant as core.async - which never blocks by the way if used correctly
it just lets you write code that looks like it's blocking
as I understand it your options come down to callbacks, promises, and core.async, in order of niceness of api
@jonpither child_process
also has sync functions, can't you use those?
something cool for lumo would be to basically block the readline prompt until some event occurs
not sure how the API would look like...
(do (.setTimeout #(lumo.repl/unblock) 2000) (lumo.repl/block))
(let [p (lumo.repl/promise)] (.setTimeout js/window #(lumo.repl/deliver p 1234) (lumo.repl/deref p))
lumo.repl/deref would pause the repl's readline (not show the prompt) until the promise is delivered
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.
@dottedmag the function passed to reduce, in this case +
itself, is called with 2 arguments
so it defers to the 2-arity version
@anmonteiro I meant third clause (two arguments), not fourth.
ah sorry
@dottedmag I read "3-arity"
so cljs.core/+
is a macro
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/core.cljc#L982
ClojureScript can have macros & functions with the same name
this is normally used for inlining
Hi @anmonteiro thanks. I knew of sync.. Ive just found a different way of approaching the problem for now.
@jonpither look at goog.async.Promise and goog.async.Deferred in google closure
@pesterhazy @nxqd @pupeno your discussion earlier prompted me to write this just now: https://www.martinklepsch.org/posts/simple-debouncing-in-clojurescript.html
Now I feel left behind....
Hah, now I remember that there also was goog.functions.debounce
:thinking_face:
Well, the more the better 馃槃
@pupeno why are you using import rather than require?
(require '[goog.functions])
(goog.functions.debounce f)
No particular reason to be honest.
relatedly is there a guide to importing/requiring in clojurescript, especially when it comes to GCL?
I always have to guess how to import GCL functions
haha same
Another thing to write about 馃槃
@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 :-)
thanks you two for writing up your findings
@pesterhazy I updated it to use require instead of import. Looks cleaner. Thank you: https://pupeno.com/2017/04/15/clojurescript-debouncer/