This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-17
Channels
- # aws (2)
- # beginners (34)
- # boot (39)
- # cider (28)
- # cljs-dev (2)
- # cljsrn (30)
- # clojure (195)
- # clojure-austin (6)
- # clojure-dev (6)
- # clojure-dusseldorf (1)
- # clojure-france (1)
- # clojure-russia (139)
- # clojure-spec (25)
- # clojure-uk (66)
- # clojurescript (125)
- # community-development (1)
- # core-async (42)
- # cryogen (1)
- # cursive (22)
- # datascript (6)
- # datomic (67)
- # docker (1)
- # emacs (7)
- # events (1)
- # garden (3)
- # hoplon (15)
- # jobs (3)
- # lein-figwheel (10)
- # leiningen (3)
- # luminus (4)
- # mount (2)
- # nginx (1)
- # off-topic (101)
- # om (42)
- # om-next (6)
- # onyx (7)
- # proton (1)
- # protorepl (4)
- # re-frame (15)
- # reagent (30)
- # remote-jobs (1)
- # ring (8)
- # ring-swagger (17)
- # rum (1)
- # spacemacs (2)
- # sql (1)
- # yada (50)
@pupeno you're creating a vector that starts with a function as it's first element, but it needs to be wrapped in parens to be a function call
@futuro: reagent will call those functions at rendering time: https://reagent-project.github.io/
Otherwise, why is tabs being called?
I have noticed that any evaluation in CLJS REPL (in CIDER) is visibly non-instantaneous: it takes ~0.1s to read-eval-print (+ 1 1)
for example. What might be a bottleneck? The target is V8 environment.
it needs to be compiled in Java code, then sent over a socket and the added as a script tag to the head (or eval'd?)
@pesterhazy Sockets and JS part ought to be blazing fast. So the most likely culprit is compiler, is it?
I'd like to debug further, but I don't know how to crack open this "put this string here and get result out of it" construction. I know how to test times of read, eval and print in Clojure separately, but CLJS is still a black magic for me.
cljs repls are more complicated than they seem
https://github.com/binaryage/dirac/blob/master/docs/about-repls.md see piggieback+weasel section
I'm integrating with a React fn, which calls a callback in my code. To that code it passes a js Object. If I used .-width
and such, advanced compilation breaks access.
What's the solution in such a case?
- externs? (but what would I specify there)
- aget (woe is me)
- gobj/get
@darwin Thanks! And "The Ultimate Guide to Clojure REPLs" linked from it is even more useful.
- darwin's oops?
- dnolen's gist style ^Class
specifier?
haha that's what I went with too, but it's the way of the devil 🙂
@dnolen, is there special casing for some attributes, like width
?
interesting
does that work only for dom objects or also for arbitrary JS objects?
to clarify, I'm not working with the DOM directly
Bah, I can't for my life get cljs-devtools injected into my chromium 55 and I feel that my project.clj is out of controle. http://paste.ubuntu.com/23815705/ All that should be needed is for me to add devtools to my :profiles :dependencies and then add devtools.preload into the :preloads array of the :clsjbuild :compiler options, right?
@pesterhazy: it doesn't matter
I use a react component that calls my function, passing me Objects with attribute like "width", "rowData", "index", "dataKey" etc
so width works, by accident, because it also happens to be a common DOM attribute, but rowData won't
didn't mean to imply you were being unclear, just trying to make sure I understood
the best thing to do, then, is just to use gobj/get always
as this is super common, it would be nice if that didn't require an additional require
or Object destructuring (let [#js {:rowData} m] ...)
though I realize that was brought up before and decided against
couldn't we just alias gobj/get
to clojure.core/oget
?
it's helpful if a function is "blessed" by virtue of being included in clojurescript's core
@pesterhazy anything in Closure Library is already blessed
and there’s no significant benefit to putting one function from goog.object
in core since all the other stuff there is also useful
auto-require goog.object
maybe?
actually goog.object/get
always seems to work even if it's not required
@pesterhazy yes because core uses it. For the record we’re not taking any ideas here 🙂
We understand 🙂
The fact that goog.object/get works out of the box is news to me, so I learned a lot. Thanks!
I can use doc
macro when in cljs.user
namespace. How do I see in which namespace this macro is defined?
@dottedmag all the REPL helpers are from the cljs.repl
namespace
@dnolen How do I figure it out in the general case? There is no reification, so I can't query it in runtime, or can I?
I see (doc)
itself prints
cljs.user> (doc doc)
-------------------------
cljs.repl/doc
, so it can be done.@tbaldridge: hey! :D so yeah the idea atm is to have each obj have full access to a cljs env and an interpreter locally, and msgs you send to it replace the interpreter with that
The rendering paradigm im looking at is based on raymarching distance functions, but can get to that later
Composing with old state at an obj is possible cuz when you send a msg you can close over old code
@nikki you can get most of that at a repl by re-deffing functions. I'm not sure what your end-goal is.
End goal is to have async actor msg passing oo, and then let complex systems evolve over time
But yeah, it's possible since a repl is such a thing, i guess the model is just to have many repls
the problem you will encounter is that Clojure runtimes are not reified. I.e. you can't go and create a new Clojure runtime without starting a new process.
In CLJ process=JVM process, in CLJS process = browser thread.
Right, for now i was thinking each obj's interpreter is just a pure function of the previous interpreter and the msg
@nikki Clojure & ClojureScript aren’t interpreters - not sure if it matters for your goals
however for ClojureScript note this also means a very large payload - which is often impractical (might not be for you)
Hi, Hoping someone can advise on a ClojureScript core.async question.
If I understand correctly core.async
in ClojureScript doesn't have the <!!
macro. In the following contrived Clojure example I'm using <!!
to effectively wait for a go
block to finish so that the greet-user
function can return the value on the msg
channel returned from the go
block:
(ns scribble
(:require
[clojure.core.async :as a :refer [<! <!! chan put! go]]))
;; imagine this is an asynchronous task
(defn get-name []
(let [c (chan)
_ (put! c "Joe")]
c))
(defn welcome-message [name]
(str "Hello " name))
(defn greet-user []
(let [name-chan (get-name)
msg (go (welcome-message
(<! name-chan)))]
(<!! msg)))
(greet-user) ;; "Hello Joe"
How can I achieve similar functionality in ClojureScript without <!!
?@mf, you have to wrap the next form in a (go ..) as well. Async code is infectious
But that's a good thing, since if you think about it, <! and >! are IO, so any function that interacts with channels is an impure function
@tbaldridge that makes sense, but the problem I have is that greet-user
needs to return the msg not a channel
It's not possible in CLJS
right
even in JS its not possible
@tbaldridge looks like some refactoring is in order. Thanks for your help
@mf, some food for thought, It's super easy to get into a situation with core.async where everything is a go block, and everything is async. Been there, and it's not pretty. So although I don't have any perfect solutions, I'd recommend trying to find ways to keep the use of core.async to a minimum in a CLJS app (or any app really). It can't always be done, and in those cases, core.async can be awesome. But it's also pretty easy to over-use.
@tbaldridge sounds like good advice. My example is very contrived. In reality I'm trying to avoid callback hell!
Is it a bug or feature that (s/from (s/nilable ::whatever))
differs for clojure.spec and cljs.spec`? For clj, it's (s/nilable ...)
and for cljs it's (s/or ...)
.
(I don't think that's the only form that differs, but I'm not aware of any other examples right now)
@miikka: bug, should be same
@anmonteiro I tried lumo over the weekend—worked out of the box and started fast. Where's the cljs repl server running, and how can I connect to it from emacs?
@pri you can create a socket server with -n port
or -n ip:port
, and connect to it from inf-clojure for example
also make sure to drop by #lumo if you need any help
there's no JVM needed in either side
Lumo runs on Node, no JVM needed
it starts a (Node) socket server
I started lumo -n 7777 and cider-connect worked but threw the error: “Sync nRepl request timed out (op clone id 1).
@pri right, which is why I mentioned inf-clojure
Lumo doesnt implement nREPL
or rather, nREPL doesn't run in ClojureScript (yet)
Given my dependency on Cider, I can't switch to any other repl. So fighwheel/nrepl is still going to be my current workflow
I spent 15 minutes reading the docs of inf-clojure and it’s not clear how to connect to a socket repl. Would you, by chance, know how?
I actually never tried, my time has been very limited these days
I did test Lumo out with a simple telnet
I can't remember the specifics, but start the server then probably something like inf-clojure-connect and you give it the hostname and port, then it should connect
If you look at the usage section of the inf-clojure
readme, you will see what you need to connect to a socket repl. Basically, you (setq inf-clojure-program '(”localhost” . 7777))
.
This works from planck as well. Basically, comint takes a cons pair for tcp connections.
Thanks, @mahinshaw I tried adding your snippet and still can't connect. @anmonteiro what editor do you use and how do you connect to your lumo’s socket repl?
Lumo 1.0.0
ClojureScript 1.9.293
Docs: (doc function-name-here)
Exit: Control+D or :cljs/quit or exit
Lumo socket REPL listening at localhost:7777.
cljs.user=>