This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-14
Channels
- # adventofcode (20)
- # arachne (11)
- # beginners (53)
- # boot (342)
- # cider (54)
- # cljs-dev (39)
- # cljsrn (4)
- # clojure (78)
- # clojure-brasil (2)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-quebec (1)
- # clojure-russia (90)
- # clojure-sanfrancisco (4)
- # clojure-spec (55)
- # clojure-uk (27)
- # clojurescript (170)
- # core-async (1)
- # core-logic (1)
- # css (1)
- # cursive (8)
- # datomic (83)
- # dirac (5)
- # hoplon (24)
- # lambdaisland (1)
- # lein-figwheel (23)
- # midje (2)
- # off-topic (1)
- # om (4)
- # om-next (7)
- # onyx (74)
- # proton (1)
- # protorepl (22)
- # rdf (2)
- # re-frame (105)
- # reagent (15)
- # ring-swagger (3)
- # rum (4)
- # slack-help (17)
- # spacemacs (14)
- # untangled (62)
- # vim (4)
- # yada (18)
e.g., I have something in src/clj/foo.clj
that I want to use in src/cljs/bar.cljs
, either as a function or its precomputed output
you either write it in cljc/cljs or call it from a macro
I’ve got some functioning Clojure written in a cljc file that works in the lein repl, but (:require [my-cljc-namespace :refer [thing1 thing2]])
doesn’t add it to the CLJS namespace. Is there some more I need to do to interoperate?
I'm trying to use slurp in clojurescript at compile time, much like https://gist.github.com/noprompt/9086232
specifically: WARNING: Use of undeclared Var cljs.core/slurp at line 6 /home/gtk/src/pairwise/src/pairwise/cljsmacros.cljc
@ashnur create new files with new namespaces
not possible to have a namespace span multiple files like in Clojure
clojure.core
, for example, is divided into multiple files
In ClojureScript this is not possible because of its compilation model
it's also not uncommon to have one big file
cljs.core
has ≈10k LOC
I know a number of projects which break them apart like this:
1. have only your public API in your project.core
file
2. have multiple
namespaces which have implementation for the internal fns
@anmonteiro i am trying to comprehend what you said but you mention things i was not aware that are relevant
i have one core.cljs now and i would like to use some functions from another file, lets say graph.cljs Besides giving a new namespace to the new file, what else do i need?
in core.cljs
you need to require
your graph.cljs
(ns myproject.core
(:require [myproject.graph :as graph]))
(graph/call-my-graph-function)
the ClojureScript compiler will parse your NS forms to figure out the order in which to load the dependencies
@ashnur I think you should go through the ClojureScript website / Wiki if you haven't already
all of this is explained there
OK to ask questions here too
especially because all the different naming conventions, i don't even recognize a lot of useful things because i don't know the difference between what is just described and what is talk about actual abstraction details
i try to search every time, but the words i look for are not the words you all use, and often there are limitations in the way i am used to do things that i don't know and it's often not mentioned in the wiki either
for example when dnolen told me to read again the dependency page, there was this phrase "build configuration" that only appears once on that page and it's not explained what it is, there is no link, nothing
took me at least 10 minutes to realize it's just the build.cljs file its talking about but for some weird reason, it's not called that but something way more general and vague
rtfm was never actually a good advice, and i feel bad about all those times when i was the one telling people to do it
hmm when I feed a vector over ipc it becomes an array?
Hi! I’m a little clueless - how do I call a JS object method (that needs access to this
) from optimized CLJS code? I’ve tried e.g. ((aget <JS object> “functionName”) <param...>))
but that seems to call the function “functionName” with this
being null
.
@ashnur it’s easy enough to add a link, I agree that would be less confusing. Feedback about confusing aspects of the existing documentation is always welcome.
not sure i should start adding links to a wiki page about a subject i know almost nothing about
@ashnur the Dependencies
page assumes you’ve not only read but actually worked through the Quick Start
, it starts off saying that - did you do that?
i did worked through the quick start, but not at once and not today but weeks or maybe months ago
and i think that there is no way i could remember details that i have not used, no matter how clearly they are expressed in the documentation
if these things could be easily explained in chat we wouldn’t have written all this documentation
@dnolen i never asked explanations in chat, it's just that it's nicer to have a link that doesn't point to a smaller book, but rather a paragraph of that book 🙂
anyway, right now everything works and stuff for me, the only reason i said anything is that i really do not understand why would you suggest to a beginner to edit your documentation 🙂
it’s the only way for things to improve, tell us what’s confusing, we’ll point how to make it better - go fix it yourself 🙂
i managed to include jsnetworkx using the cljsjs method and then i realized that it does not support the algorithm i want (talk about stupid 😞 ), so now i am implementing a different algorithm anyway 😄
yes it’s very Lisp-y, !
, ?
, +
, ’
are all nice to use in names if you’re a Lisp programmer
@dnolen I assume you edited the Wiki
we should probably keep the site in sync too
@anmonteiro yes, I added one link - and I switched cljs.closure/build
-> cljs.build.api/build
i saw !
and ?
used for naming but i actually never saw names that contain +
and ’
. is there any naming convention or particular situation in which i might want to use them? doesn’t ’
cause any issue with the evaluation if positioned at the beginning of the name?
for math-y convention you actually mean math related function or, like in the example, list manipulation (add/remove elements) stuff?
@acron thanks, but it gives the same warning. It basically gives the same warning in every case, but also works in every case, so ¯\(ツ)/¯
feel free to open a JIRA issue about that case though, it seems relatively simple to fix
are there any resources online WRT allowing a cljs lib I've written to be consumed from JS as an es6 module? lots of resources online around the inverse - bringing es6 modules into cljs - but those dominate search results and are making it hard for me to find the opposite 🙂
@samueldev Check out this repo: https://github.com/typeetfunc/datascript-mori They're doing that I think
how do i write guards for loops so they don't block the whole browser and i don't have to restart even lein to be able to use anything?
@dbsgtk I commented in the ticket, but not sure CLJS-1872 is a bug
if you wanna use slurp
you need to put it under a reader conditional
@samueldev doesn’t ES6 have story for loading plain JS libs
clojure.core
is aliased to cljs.core
by the ClojureScript compiler, which is why you get the undeclared Var warning
@anmonteiro he wrote a slurp
macro
he's still requiring a .cljc
file which calls clojure.core/slurp
when he :require
s it, it's also evaluated in ClojureScript, which is why he's getting the warning
he probably just needs to put the macro under #?:clj
that wasn't clear to me too until I saw CLJS-1872
I'm seeing a weird error when trying to require cljs.repl.node
:
user=> (require '[cljs.repl :as repl])
nil
user=> (require '[cljs.repl.node :as node])
ClassNotFoundException cljs.repl.IParseError java.net.URLClassLoader.findClass (URLClassLoader.java:381)
user=>
this "just worked" last time I touched it, which was a few months ago, and as far as I can tell nothing in my project has changed@dnolen you misunderstand, i know javascript very well, and i know that's not possible to achieve in general, so when i work with loops or recursion, i always have a guard that when in javascript i just update normally with ++ and have a limit that's larger than the dataset but small comparatively (like 3000 or smth). I was asking how should I achieve the same thing in clojure?
@ashnur I don’t understand the question. That’s not idiomatic JS or anything. So just write a similar guard in ClojureScript if you like
@ashnur: maybe look here: https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/dispatch.cljs
but there are far more recursion patterns so you’re unlikely to come up with something that will work for all cases in Clojure(Script)
@dnolen this is some silliness that is happening here, i am messing up the syntax probably or similar issue. seeing examples helps me personally a lot in this situations.
It's going to be better for you to learn the idiomatic abstractions Clojurescript provides rather than trying to cram concepts from JS into CLJS.
@fellshard i agree with that completely
I was reacting to this part of the sentence "guards for loops so they don't block the whole browser”, didn’t understand the lein part 🙂
yes I know, I’m explaining that it’s going try to print whatever the browser had sent up to the point you killed it
what i am thinking is that i build something small, will share the code and then you will tell me how in clojurescript this is done differently. 🙂
i usually just write the naive implementation first and scour the clojure docs for interesting library functions that do it better
for me best works reading others’ people code, usually when I need/want to use it and start depending on it 🙂
hmm, http://cljsfiddle.com is blocked by the company firewall
https://stackoverflow.com/questions/41148860/canonical-way-to-use-clojure-code-in-clojurescript for sanity
Do anyone have links to explanation or examples for consuming a javascript react library like https://github.com/tomchentw/react-google-maps? Most React libraries have documentation examples in JSX, I’m trying to figure out how to translate that to something I can use in CLJS.
I’m also interested in hearing anything to the effect of “it’s not worth it” If that’s your experience
if you're using reagent then you can "adopt" the class for direct use in hiccup-like templates
@adamfrey even if it's not, you can probably use js/React.createElement
that's what JSX translates to
<Foo x=42>
<Bar/>
</Foo>
^ this is the same as:
(js/React.createElement Foo #js {:x 42}
(js/React.createElement Bar))
I’m trying to do something similar to a map destructure in CLJS, I was hoping
(let [[rows scroll-height style] ((juxt .-rows .-scrollHeight .-style) (.-target event))] …)
would work, but the closure compiler complains because the .-
shortcuts aren’t proper methods, I should have seen that coming. Is there something else people do to destructure multiple JS properties at once?@anmonteiro @dnolen I can certainly accept that's its not a bug, but can you help me understand what I did wrong?
FWIW, when I use clojure.core/slurp
explicitly in the macro, I got an undeclared var on that.
@dbsgtk: the macro needs to be put under a :clj
reader conditional so that ClojureScript doesn't see it
In ClojureScript macros are written in Clojure. By :require
ing the file you're making it be compiled in ClojureScript too
@pld: alternatively: https://github.com/binaryage/cljs-oops
@adamfrey To use react-google-maps in cljs see the cljsjs package: https://github.com/cljsjs/packages/tree/master/react-google-maps