This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-09
Channels
- # beginners (121)
- # boot (28)
- # cider (106)
- # clara (57)
- # cljs-dev (70)
- # cljsrn (6)
- # clojure (145)
- # clojure-dev (7)
- # clojure-italy (36)
- # clojure-russia (42)
- # clojure-spec (26)
- # clojure-uk (127)
- # clojurescript (103)
- # core-async (10)
- # cursive (56)
- # datascript (66)
- # datomic (16)
- # defnpodcast (1)
- # emacs (18)
- # events (6)
- # figwheel (1)
- # jobs (1)
- # luminus (1)
- # lumo (44)
- # off-topic (58)
- # om (17)
- # onyx (2)
- # parinfer (75)
- # pedestal (4)
- # re-frame (18)
- # ring (4)
- # ring-swagger (8)
- # rum (7)
- # spacemacs (7)
- # specter (2)
- # sql (4)
- # unrepl (39)
- # untangled (17)
- # vim (3)
- # yada (21)
@michaelmrose I haven't scrutinized the birch script you referenced (it is not immediately clear to me if it trying to be lazy), but it is the case that ClojureScript doesn't have locals clearing. More info here http://blog.fikesfarm.com/posts/2016-01-15-clojurescript-head-holding.html
Thanks @mfikes interesting read
When using reagent/om, is there a way ot "preload" images? Right now, images appear to be loaded WHEN THEY ARE NEEDED ... which sometimes causes delays / flickers. When I know for a fact that I will need an image, is it possible to pre-load it (without displayint it) ?
@weavejester what do you mean by “finding out more” about an analysis error?
Hi all, maybe some one can help me... How i can provide check for undefined prop in js obj? I've try something like this (if (= (aget jsobj prop) nil/"undefined"))
but it doesn't works 😞
@osmirnov maybe (gobj/containsKey jsobj prop)
? see https://google.github.io/closure-library/api/goog.object.html
@osmirnov You have the choice:
(exists? (.-fooo js/window))
(js-in "fooo" js/window)
(undefined? (.-fooo js/window))
When calling js from a macro do I have to ns qualify it somehow in order for it to see the actual DOM? I'm getting errors like document.getElementById(...).width is not a function
@sophiago looks like you are emitting code that wants to call that as a function and not a property access
if you emit (js/...)
that is already namespace qualified as far as the macro is concerned
Ah, ok. I don't do much js interop in general and haven't had to query an element's width/height before.
.width and .height are properties whereas .getElementById() is a function. So it seems properties are what you qualify with (js/...)
Hello. Is there information how the (cljs-repl) in figwheel (chestnut) works? I have a raspberry pi development scenario where I develop on my laptop but run the leiningen repl remotely on the raspberry pi. The cljs-repl isn't able to connect in this case. It just hangs.
@gv I'm not sure, but have you tried pointing your browser at localhost:3449/index.html
?
It's been a long time since I've had to deploy cljs and I've either totally forgotten how to get it to compile to one js file or it's not doing it automagically since I didn't have my project.clj set up for figwheel back then. Would anyone mind reminding me how to go about this, i.e. without needing a dependency on /goog?
yes, I visited raspberrypi:3449/index.html in the browser on the laptop which shows the example page
Oh. Sorry, it's quite late here and I didn't read close enough to see you're developing on your laptop. I'm really have no idea about a workflow like that.
it also needs to know at compile time whether a name resolves to a var right? like that isn't latebound
I am not sure that :websocket-url is what I am looking for. The remote nrepl should be the websocket host as far as I can tell and that is the default
@thheller if you're familiar with http://www.selflanguage.org -- they implement "messages" for objects by basically sort of eval'ing in the scope of an object (as a reified namespace sort of) but objects also inherit names from parent objects
I've tried to abuse namespaces before as well and feel like how Clojure overloads them sort of invites that. But Self is quite different. It's a prototype based OO language (like how OOP began with Smalltalk, or these days in Lua or JavaScript). Alan Kay did get the idea from Lisp, though. It's quite simple to polymorphism via message passing in Lisp (although I think Clojure protocols are a huge step forward).
Here you go 🙂
(defn make-from-real-imag [x y]
(fn [op]
(cond (eq? op 'real-part) x
(eq? op 'imag-part) y
(eq? op 'magnitude) (sqrt (+ (square x) (square y)))
(eq? op 'angle) (atan y x)
:else (println (str "Unknown op -- MAKE-FROM-REAL-IMAG" op)))))
That's an "object" implemented with message passing style, i.e. dispatches to different operations by passing their name as a symbol, that converts between complex numbers in polar and rectangular form. Ported from Scheme.
nice @sophiago :D but ya i mean having "eval" inside an object where the locals are the objs locals plus parent stuff... haha
The snippet above is message passing style, which you can see achieves pretty much the same result as Clojure's protocols. Sounds like you just mean a prototyping language. Doesn't make much sense to implement one in Clojure, but I'd think the best way to do it would be with continuation passing style (I've used ad hoc continuations in Clojure projects before and seem to remember David Nolen having a delimited continuation library).
If you open the browser on your laptop it needs to connect to the RP, so you should give it the IP of the RP
@rauh: ah right. so the default isnt derived from the other :host options? I already specified the host for the jetty server in project.clj
Yeah I'm not sure, figwheel does get the port automatically and it should work. See the code in figwheel.cient
.
The Jetty shouldn't have anything to do with the host/port. That's your server I assume?
@rauh: sure, it is the server and I had to provide the IP there to be able to access it remotely 😉 I'll try the :websocket-url configuration later. thank you
I should probably try asking this again... It's been a long time since I've had to deploy cljs and I've either totally forgotten how to get it to compile to one js file or it's not doing it automagically since I didn't have my project.clj set up for figwheel back then. Would anyone mind reminding me how to go about this, i.e. without needing a dependency on /goog?
@sophiago should happen if you set the :optimizations
to :advanced
for your production build
I've tried both (using figwheel, cljsbuild, and running the release.clj with java -cp) and it still needs at least a goog 😕
Although with the release.clj method I wasn't certain I was specifying the main class correctly given I don't have a main function
If you're using lein-cljsbuild, you should have builds like this: https://github.com/emezeske/lein-cljsbuild/blob/1.1.5/example-projects/advanced/project.clj#L52-L75
The command I'm using is lein cljsbuild once
and I do have :optimizations :advanced
set
@gv by default figwheel will connect to localhost:3449
, but you can override in your project.clj .
Add the :websocket-host
option for figwheel configuration. For example:
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs"]
:figwheel {:websocket-host :js-client-host
:on-jsload "my-app.core/on-js-reload"}
:compiler {:main my-app.core
:output-to "resources/public/js/dev/app.js"
:output-dir "resources/public/js/dev/out"
:asset-path "js/dev/out"
:source-map true
:source-map-timestamp true
:preloads [devtools.preload]
:external-config {:devtools/config
{:features-to-install :all}}}}
:js-client-host
is of special meaning for figwheel. This will tell figwheel to connect to the same host as the current page is running. So if you have opened raspberrypi:3449/index.html
, it will connect to
Hey! Does any one have an idea what could be wrong here? I am sending request in transit format with cljs-ajax with data containing a sequence. There are no problems in dev environment. However, in production it fails with exception in transit-cljs: Uncaught Error: Cannot write Function
. Looks like this is related https://github.com/cognitect/transit-cljs/issues/30 . But things get even more weird, when i try to run production build locally, no exception is thrown
@pradyumna: thank you
Digging into CLJS analyzer stuff. How can I eval a form from within a macro?
Given this snippet. How do I analyze/resolve/eval (inc val)
form?
(def val 1)
(mymacro {:key (inc val)})
if you wnat to evaluate the entire thing, why not just return the form? that;s what clojure does anyway
I guess if a form makes use of a var from another namespace resolving will fail.
derp, sorry; I just realized you said cljs-analyzer and completely misunderstood your question, because I’m in the wrong slack channel
So when I run analyzer on a form which uses vars from another ns I get errors about those vars are missing.
For context: I'm trying to eval a form to see if I can retrieve a value statically.
Does anyone here know a good way to get lein doo test
to print out colors green/red or something other than black and white?
But it seems to be pretty much unmaintained. Curious if there's something everyone else is using for this that I'm unaware of.
@dnolen could you please explain this? https://clojurians.slack.com/archives/C03S1L9DN/p1497022661938796
@roman01la what does that mean?
A macro accepts a form which has a var from another ns. Is it possible to evaluate this form in a macro so that I could retrieve result at compile time.
Basically do function call inlining.
@roman01la yeah I do not understand
Hm. Even if there's nothing cljs/js specific?
@roman01la then why not just call Clojure eval
?
Followup on my previous question... how are you all testing ClojureScript code? Do you just use clojure.test, or is there something with more assertions, color-coded output, etc that you use?
@dnolen not sure if this would work if the form includes a var from another ns
roman01la: did u get this working? i had a similar situation, which i solved by using (bind [*ns* foo.bar]... )
plus some require
statements.
@chrisdavies idk what people are using to prettify test output, would be great to get a PR for that in doo
@chrisdavies I use clojure.test
and lein-doo
and am also curious how to make assertion reports more readable.