This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-01
Channels
- # aleph (71)
- # aws (1)
- # bangalore-clj (4)
- # beginners (36)
- # boot (153)
- # cider (23)
- # clara (9)
- # cljs-dev (67)
- # cljsjs (2)
- # cljsrn (22)
- # clojure (348)
- # clojure-argentina (4)
- # clojure-austin (12)
- # clojure-berlin (9)
- # clojure-dusseldorf (6)
- # clojure-france (4)
- # clojure-italy (4)
- # clojure-russia (358)
- # clojure-spain (2)
- # clojure-spec (28)
- # clojure-uk (109)
- # clojurescript (130)
- # core-typed (1)
- # cursive (35)
- # datascript (6)
- # datomic (18)
- # emacs (12)
- # hoplon (4)
- # klipse (64)
- # lein-figwheel (13)
- # leiningen (3)
- # luminus (4)
- # lumo (51)
- # mount (22)
- # off-topic (83)
- # om (22)
- # om-next (8)
- # onyx (3)
- # pedestal (8)
- # perun (6)
- # portland-or (2)
- # re-frame (50)
- # ring (8)
- # ring-swagger (5)
- # untangled (10)
- # yada (9)
you can read more here: https://github.com/zealdocs/zeal/issues/170#issuecomment-71310603
apparently there is a feed now, I am going to try it right away https://github.com/zealdocs/zeal/issues/170#issuecomment-269930023
@ejelome tried it and it works, just paste http://zealusercontributions.herokuapp.com/docsets/ClojureScript.xml in Add Feed
I’m trying to receive a request using cljs-http. While running my tests with lein doo phantom, I receive a -1 status and an empty string as the body. However, when I run the test in the repl, I am able to retrieve the request data. Is this because a channel is being returned first? Or maybe I need to implement a timeout to wait for the request to complete?
there are some problems with using js/isNaN
to check for NaN
- http://adripofjavascript.com/blog/drips/the-problem-with-testing-for-nan-in-javascript.html
the recommended approach in js is to check foo === foo
, can i rely on the same behaviour in cljs? i.e. (= foo foo)
a quick noodle in the cljs repl says this should be ok
but are there edge cases i might need to consider?
@thedavidmeister you can use (== foo foo)
==
is for numbers
i didn't know about that one
cljs.user=> (== NaN NaN)
false
cljs.user=> (def foo NaN)
#'cljs.user/foo
cljs.user=> (== foo foo)
false
oh actually looks really useful
i've had to do some weird juggling of number types in the past because i didn't know about this
thanks 🙂
@bones did you implement ISeq
though?
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L516
`(extend-type js/HTMLCollection ISeqable (-seq [array] (array-seq array 0)) IIndexed (-nth [array i] (get (array-seq array) i)))`
I don't see ISeq
seems to be what destructure
checks for... https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/core.cljc#L658
sure
cljs.user=> (doc ISeq)
-------------------------
cljs.core/ISeq
Protocol
Protocol for collections to provide access to their items as sequences.
-first
([coll])
Returns the first item in the collection coll. Used by cljs.core/first.
-rest
([coll])
Returns a new collection of coll without the first item. It should
always return a seq, e.g.
(rest []) => ()
(rest nil) => ()
nil
^ this is in Lumo
works in a normal (JVM) CLJS REPL too
awesome! thanks @richiardiandrea 🙂 https://clojurians.slack.com/archives/clojurescript/p1485907215014542
when compiling clojurescript to .js files, how can I force macro namespaces to be compiled to .js files too? This is to then use the $macros.js with self hosting
@tomaas are you using CORS? sounds like your preflight route also requires the x-access-token and x-key headers
We are building a couple of apps and parts will be common - panels / backend calls etc. is there anything I can read or any pointers on how to structure such a thing
https://clojure.org/reference/datatypes - deftype and defrecord dynamically generate compiled bytecode for a named class
@ashnur many things just got copied over from Clojure, feel free to send PRs with corrections
@ashnur I believe the description you linked to is saying that, under the hood, deftype and defrecord are building what java would call a class
or technically “the same bytecode that would have been generated by a Java class"
no wonder the docs suck if the newbies are writing it, is my usual reply, i don't see the logic behind the concept
first off, this is the clojurescript channel, so @dnolen assumed you've found something that was incorrectly ported over from the clojure docs
@moxaj, and i used the clojure docs because i did not found clojurescript specific documentation about defprotocol or protocols
also, i watched this, but it only tells half the story https://vimeo.com/11236603
@ashnur oh sorry I missed you were talking about http://clojure.org
@ashnur what are you looking for specifically? most of the deftype
docs for Clojure apply to ClojureScript
we could make a page for ClojureScript specifically about the small differences + document specify
@dnolen i am just trying to understand how protocols can be used, i have to implement a graph lib and i would like to do it nicely
@dnolen I get WARNING: Cannot infer target type in expression (. Foo -prototype) ...
for a simple (defrecord Foo [])
, I assume this is not intended? This seems like it should be common enough, but I don't see a jira ticket.
@ashnur I have seen a lot of references to http://www.braveclojure.com/multimethods-records-protocols/#Protocols
@dnolen just to clarify, you mean there's a minor ticket already (which I can't find), or that i'm free to file one?
@dnolen is there a way to get the closure compiler to compile all macro namespaces for use with self hosting? So that you can have load-fn use a .js and cache file for macros instead of clj/cljc sources?
@thegeez hrm, I don’t really understand what you’re asking for - mislead here by your mention of Closure Compiler
I mean when cljs.js is required, then core$macros.js is generated. I was hoping there was a way to get all macro namespaces to be generated as such
@thegeez You can, as an AOT step, require macros namespaces and then cache the results. This is in fact what Planck and Lumo do for certain namespaces so that they can subsequently be required w/o actually having to convert them to JS. More info is here http://blog.fikesfarm.com/posts/2016-02-03-planck-macros-aot.html
ok, so now i understand the syntax (i think) but i have this issue that i can't see the difference between the protocol and the record. I both want them named Graph
like, i want a graph lib that has methods such as erdos-renyi or watss-strogatz that generate random graphs
@ashnur it is fairly common to prefix the protocol with an I
to indicate what would be an interface
in java. ie. (defprotocol IGraph ...)
and (defrecord Graph ...)
ok, so by convention i should just put an I in front of the protocols name so i can have IGraph protocol and Graph record
people use all sorts of naming but the I
version is most common I think. clojure and cljs do that all over the place
@nrako that is an attribute, so (-> target (.getAttribute "data-record-id"))
should work
depending on the browser you can do (.. target -dataset -dataRecordId)
but getAttribute
is safer
@borkdude depends
there's also lumo.core/*command-line-args*
@anmonteiro is that available from a script?
but depends on what you want
*command-line-args*
works like clojure.main
@anmonteiro I get this: WARNING: No such namespace: lumo.core, could not locate lumo/core.cljs, lumo/core.cljc, or Closure namespace "" at line 3 W
need more info
Lumo version, did you require lumo.core
?
@anmonteiro Should the cache work if I run lumo only with a script?
What do you mean? Can you paste the command you're running?
@anmonteiro I mean, say you have a file script.cljs
with only (println “foo”)
and you call it with lumo -K script.cljs
@anmonteiro should this compile anything into the cache
Probably not
Only of you require stuff
@anmonteiro this is my script now: https://gist.github.com/borkdude/a6a87796dfe26218a5e9164a84545790
I call it with ./node_modules/lumo-cljs/bin/lumo -K script.cljs <some-file>
, but the cache stays empty. Maybe lumo only caches compiled things from the “init path” or “class path". But with the -i option I couldn’t pass a command line arg.
@borkdude: I'm busy right now, but feel free to open an issue with an example that I can look at later
@anmonteiro ok, I will and thanks!
I’ve been trying to use Leiningen and Stuart's "Clojure Reloaded" workflow so I got a file user.clj
on my source path that transitively requires a couple of Java classes in my project and despite some efforts I keep stumbling upon ClassNotFoundException
. It appears to be reported in some issues (e.g. https://github.com/technomancy/leiningen/issues/1245) but unfortunately there are no well-known solutions 😕 How have you guys deal with this?
Good idea, thanks! https://clojurians.slack.com/archives/clojure/p1485985651017834
is there any JS or CLJS library for GraphQL which could be used from CLJS out-of-the-box?
does anyone know a cljs lib that has a deep merge fn for maps?
@michael.heuberger Like merge-with
but deeper?
but hasnt been ported yet
yeah, could do but dont want to copy/reinvent or so if possible