This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-29
Channels
- # adventofcode (4)
- # beginners (113)
- # boot (165)
- # cider (192)
- # cljsrn (82)
- # clojure (148)
- # clojure-austin (6)
- # clojure-russia (22)
- # clojure-spec (45)
- # clojure-uk (19)
- # clojurescript (153)
- # core-async (5)
- # cursive (7)
- # datomic (2)
- # defnpodcast (2)
- # emacs (1)
- # hoplon (617)
- # instaparse (10)
- # lein-figwheel (19)
- # luminus (2)
- # off-topic (12)
- # om (3)
- # onyx (36)
- # pedestal (1)
- # protorepl (43)
- # re-frame (8)
- # ring (7)
- # specter (17)
- # testing (2)
- # untangled (117)
- # yada (12)
hi guys, I'm looking forward to update cljsjs react-dates but I'm not sure how to generate extern for this lib. How can we get the single js file to generate extern file ?
Hey, looking for a way of selecting items from a Vector using Specter (like srange but for any index), couldn't find a way of doing: (select [ALL <?>] [[1 2 3 4 5] [1 2 3 6 7]]) -> [[2 5] [2 7]]
There is multi-path
(select [ALL (multi-path (keypath 1) (keypath 4)) ] rs)
but it flattens out the result
Has anyone used both cljs-http and cljs-ajax, and could give any feedback on their pros and cons?
Forgive me if this is a frequent question. I've been looking for an idiomatic way to perform HTTP requests, and have found an overabundance of resources. It's hard to choose!
(Or, if all I needed for now was to do GET requests, would you recommend just using goog.net.XhrIo and core.async?)
Thanks @anmonteiro
Hello, I'm developing a script in cljs on nodejs. For release (=production) build I want to have a single file with all my code, for which I use :optimizations :simple
but looks it like it minifies my variable names. Is it possible to not have the variable renaming? It's pretty uncomfortable to see a.request is not a function
.
I am using sourcemaps, but the exception is still TypeError: a.request is not a function
, also sourcemap suggest error to be one line above the actual line (I have a s-exp splitted into 2 or 3 lines there)
Regarding :whitespace java.lang.AssertionError: Assert failed: :nodejs target not compatible with :whitespace optimizations
😞
So it might be that there's nothing better to do than to fill a feature request or something? 🙂
my experience here is also shallow but i believe you will need something like https://github.com/nervous-systems/cljs-nodejs-externs in order that the closure compiler will not alter those symbols
hope it helps! see also the docs on externs https://github.com/clojure/clojurescript/wiki/Dependencies#using-externs
@karolisl, simple solution: use optimization: whitespace
don't think simple optimization offers significant benefits when running on node
@pesterhazy sadly, but I cannot do that: java.lang.AssertionError: Assert failed: :nodejs target not compatible with :whitespace optimizations
wow, who knew?
sorry for the noise
I'm curious why whitespace won't work with node
well there's the clojurescript jira: http://dev.clojure.org/jira/browse/CLJS
Strange. https://groups.google.com/forum/#!topic/clojurescript/dCu5J7ngezE Looks like it should be fixed by now, but with latest cljs and lein-cljsbuild versions I still get the same assertion errror. 😞
the check is still in master: https://github.com/clojure/clojurescript/blob/97d2d61e78ce747d02d0e5b2ced706f6fb68ec4e/src/main/clojure/cljs/closure.clj#L1787
(ns cljs.install
(:require [cljs.nodejs :as node]))
(println "Script initialized")
(node/require "util")
(def process (.-spawn (node/require "child_process")))
Is there a different way to set variables for js objects in clojurescript? the following code results in a TypeError Cannot read property 'process' of undefined
@aengelberg we create ClojureScript compiler 2 artifacts, 1) is normal sources JAR 2) the other is AOT'ed
the later loads significantly faster since you don’t have to compile 10,000 lines of Clojure to start compiling ClojureScript
if somebody is trying to get this working with Lein though, it’s not your problem - I’ve never been able to get it work
I am using reagent for the first time (first time using anything reacty) and am trying to build a pair of input components where editing one changes the value in the other
e.g., you could imagine a celcius:left_right_arrow:fahrenheit converter
the happy case I got working fine by having one piece of global state that they both display the value of
but I'd like the text boxes to support invalid input
where it shows an error message below, but leaves the bad input in the text box for the user to edit
but if the user goes to the other box and puts something valid there, the bad input in the other box would go away
my hunch was that I needed local state for each component to hold its current value, but I'm not sure about how to wire the whole thing together
currently I have a local atom for each component, and a global atom for the state that gets updated on valid input; but I can't get the effect of " if the user goes to the other box and puts something valid there, the bad input in the other box would go away"
I imagine I could hack something together by stapling more global state to more side effects, but I'm hoping there's some Better Way to do it
can someone explain what’s going on under the hood to make this happen?
(let [win js/window]
(.-innerWidth win))
=> 1920
(let [window js/window]
(.-innerWidth window))
=> TypeError: Cannot read property 'innerWidth' of undefined
if you’re messing with this in a REPL simple to do by wrapping your expression in (fn [] …)
Hi I'm using LightTable and within lightTable my code renders in a Browser Tab (awesome!) but I would also like to preview it in a browser. I have figwheel running in a separate terminal, but connecting to localhost:3449 only loads the html page, not any of the associated js...
thanks for the (fn [] …)
technique, David. It doesn’t look like a CLJS code gen problem, it’s a quirk in JS that I didn’t know about.
function broken () {
var window = window;
return window
};
broken() => undefined
well it'd be nice if cljs wasn't sensitive to that; but that might be impractical, I dunno.
oh wait
okay so cljs locals can shadow the global js namespace I guess?
@gfredericks yes they can. Which I guess I didn’t realize until now
is there no reliable way of getting at it?
I thought generally js/window
was the entrypoint to the global ns but if window
itself can be shadowed then I don't know what fallback there is
if window
really is unique and special I suppose cljs could special-case-munge it for locals
here’s an example of that shadowing, for reference:
(fn []
(let [window 1]
(inc window)
(.-innerWidth js/window)))
=> #object[ret__8703__auto__ "function (){
var window = (1);
(window + (1));
return window.innerWidth;
}"]
I also feel like the answer might be “It’s not practical to avoid this"the compiler already has to munge things
if it's just an extra line of code in the compiler somewhere, I have a hard time believing that's worse than saying every cljs programmer everywhere has to remember to never use window
as a local name
test.x = (function test$x(){
var window = (1);
(window + (1));
return window.innerWidth;
});
@adamfrey You can probably add navigator
and document
to the list. See https://www.youtube.com/watch?v=mHtdZgou0qU#t=7m
Hrm. I’m stuck on a way to return a symbol from a fn… if that’s even the right strategy. The pandeiro/boot-http lib for http-proxying accepts a :handler ‘my.app/some-ring-handler
argument (a symbol). If I wanted to do something like
...
(boot-http/serve :handler (make-proxy “/my-api/” “”)
...
I would need to return a symbol for serve
. How does one generate a function inside a function, and instead of returning the generated function, return a symbol for that function? Is this totally incorrect?@lwhorton Are you sure it's 'my.app/some-ring-handler
and not #'my.app/some-ring-handler
?
If I were to simply define a proxying function as a let block, and return the symbol of that fn, does a closure hold onto that symbol?
(defn make-proxy [args]
(let [prox (-> routes (wrap-proxy args))] (symbol “my-handler” prox))
?@peeja it does yes, https://github.com/pandeiro/boot-http#3-start-server-with-given-ring-handler
I'd expect to be able to pass a function instead. Have you seen whether that works yet?
A symbol is convenient on the command line, but if you're specifying it in clojure-land anyhow, I'd hope a function would work too
@lwhorton you might have better luck asking about this in the #boot channel too since this is more related to using boot
I was considering that, but this was also interesting as a more general clojure question
But to answer the Clojure part of the question… a symbol is just a value, like a string
Can you bind a local symbol and return it, and expect the lookup sym->var to “stick around” in a closure?
The only relationship it has with the function is that if you look up the var named by that symbol in the namespace, you'll get a var that contains a function
When the compiler reads foo
inside a let
that binds foo
, it connects that reference to that foo
. If it doesn't see a local binding, it resolves it as my.ns.some-fn/foo
instead
If symbols just name vars why do we need them, and why can’t we go straight to a var?
It's treated specially by the reader, though: when the reader finds it, it tries to resolve it to a value
Symbols are important, for instance, in macros, where your code is given the actual forms in the call the user made
So, if you call (my-macro foo (bar baz))
, your my-macro
gets two arguments: the symbol foo
and the list of two symbols (bar baz)
i see... thinking about them as primitive values passed around to later be resolved makes it more clear
and often it's convenient to pass the var containing that function, because you can call a var like a function and it will pass the call on to the function inside it
but if you change the definition of the function (say, by changing the code at dev time and reloading it), the var will now point to the new definition, and you won't have to reload your server to get the new handler function into it
But passing a symbol to an HTTP server as the handler is pretty weird, and probably only used here because typing myapp.server/app
at the boot CLI passes a symbol to the function
hello, I'm having a strange compilation problem with ClojureScript
my project compiles fine with :none
optimizations
but by trying any other compilation I'm getting the error:
I tried to modify my project, and try to compile a simple file containing only a (def hello "world")
even trying to compile only this, the error still happens
I tried removing dependencies, and after a fill tries I figured that Datomic dependency seems to be the one causing some problem
by removing the [com.datomic/datomic-pro "0.9.5530"]
dependency the simple file starts compiling again
any idea what might be happening? I'm stuck with what to try next
Perhaps lein deps :tree
can provide some insight?
thanks @henriklundahl , I figured the guava dependency on datomic and clojurescript are clashing somehow, following the recomendations on lein deps :tree I removed guava from clojurescript first, but that was erroring, by excluding it on datomic the cljs compilation worked
well, datomic doens't even need to be load to compile cljs, maybe a good idea would be to put it in some profile and remove that profile while compiling the JS, I'm afraid excluding it from datomic dep might cause some problems running datomic on the server
I'm trying to extract some of my code in a clojurescript web app into a library to be shared with another project. Is there a standard, modern, plain lein template for a clojurescript library?