This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-11
Channels
- # beginners (109)
- # boot (61)
- # cider (8)
- # clara (3)
- # cljs-dev (67)
- # cljsrn (5)
- # clojure (96)
- # clojure-argentina (1)
- # clojure-brasil (2)
- # clojure-greece (10)
- # clojure-russia (114)
- # clojure-spec (51)
- # clojure-uk (45)
- # clojurebridge (2)
- # clojurescript (139)
- # cursive (18)
- # data-science (1)
- # datascript (2)
- # datomic (13)
- # dirac (2)
- # emacs (5)
- # events (1)
- # javascript (2)
- # jobs (1)
- # juxt (3)
- # off-topic (62)
- # om (10)
- # onyx (12)
- # perun (7)
- # ring-swagger (7)
- # specter (21)
- # test-check (5)
- # untangled (16)
- # utah-clojurians (1)
- # yada (2)
I tried leaving vim and I had the same problem... and somehow my eyes don't feel comfortable without vim's default color scheme which isnt avaliable anywhere else out-of-the-box... 😞
for home-brewed code (non libraries), can you get away without writing any javascript using cljs or do you ever have to fall back to js?
personally I haven't had the need to fallback to JS even when writing libraries (or JS library wrappers)
Has anyone run into an issue with lein-doo
where it would not flush correctly to stdout? I’m running lein via node
and finding it hard to debug tests involving large spec
maps when it refuses to print out the entire error 🙂 https://gist.github.com/pithyless/b45fe5c7d77906d30a3d490e84e1ddf3
@mping I normally use core.async
, though it might be an overkill depending on your use case
@anmonteiro I’m dealing with a js lib that returns promises, I want to map it to cljs standard idiom
@mping right maybe I should have detailed my answer a little bit more. Here's an example to get you started:
(let [ch (cljs.core.async/chan)]
(-> (fn-that-returns-a-promise)
(.then (fn [result] (cljs.core.async/put! ch result))))
ch)
if you return that ch
from a function, you can then take from it somewhere else
ok I do it by hand then 🙂 I thought there was a wrap-promise-to-chan
thing although that shouldnt be hard
(go (let [my-result (<! (fn-that-returns-a-channel))]
;; do stuff with my-result
))
@mping i haven't tried this library, but perhaps it could help? https://github.com/jamesmacaulay/cljs-promises
go
is cljs.core.async.macros/go
, and <!
is cljs.core.async/<!
it's basically doing exactly what anmonteiro suggested by wrapping the js/* functions with core async
if you're working directly with js interop you can handle errors like this:
(-> (js/my.Constructor. (clj->js params))
(.promFunc1 (clj->js some-other-params))
(.then (fn [q]
(.log js/console "success" q))
(fn [error]
(.log js/console "fail" error))))
Hi 👋 the cljs-promises readme example shows the use of the included <?
macro, which raises an exception if the promise resolves to an error
Haha yeah I slack notified me from the GitHub URL :face_with_rolling_eyes:
FWIW, cljs-promises works a bit differently from what @anmonteiro suggested
cljs-promises extends js Promises with the core.async ReadPort protocol
so you use the promise directly as a channel, and when you do so you can repeatedly read from it and get the same resolved value/error repeatedly
in the earlier suggestion here, it created a channel that – I believe – only gives you the value once
oh oops, my apologies. i gave it a really quick look. out of curiosity, is core.async's promise-chan
somehow relatable to promises in cljs?
part of the motivation for cljs-promises was wanting to take advantage of how you can share promises between different parts of code and the different consumers can not care
yeah I was going to mention promise-chan
it came out after I wrote that library
from what I remember it has very similar semantics
never seen promise-chan implemented? like, never seen it used in practice?
while promise-chan has similar semantics to js Promises, in cljs they don't have any special relationship
I think a promise-chan
would be the most appropriate thing to return from e.g. an HTTP request function in clj/cljs
but I guess maybe it never really caught on
i'm confused how a promise-chan
differs from a standard chan
. isn't (go (<! http-request
the same thing?
biggest difference isn't really made clear in the documentation
which is that multiple consumers can repeatedly take the value of a promise-chan
for as long as they want (until someone closes the promise-chan
)
whereas with a regular chan
, someone would put a value on once and then only one other consumer could get that value, once
the other difference is that once someone puts one value into a promise-chan
, no other values can be put into it
this has better explanation of details than the docstring: http://dev.clojure.org/jira/browse/ASYNC-103
you may have independent code that all need to wait on some value but may subscribe at different times
@jamesmacaulay how do I install the thing? didnt find any link to clojars..
Dependencies are definitely out of date, haven't touched it in a long time
If you have any trouble let me know
so my running
boot cljs
seems to do nothing. it does not really seem to generate anythingI changed my boot version to 2.5.5 (the version in modern-cljs) and set BOOT_EMIT_TARGET to no
I guess you need to do boot compile taskname
, my memory may be forgetful, but with lein you can do lein cljsbuild once.
ok, just make sure you are not using boot cljs development build I would guess some websocket juice is added that you dont want in production.
I dont even have enough mental scaffolding to be properly cautious of that problem yet.
Are you looking to develop clojurescript project or do you have something ready that you want to build and deploy?
If you are developing with boot, in contrary to leiningen/figwheel, you don't want to see the directory with the js files, but have boot do it all automatically for you, to get auto reload everytime you save the .cljs file etc.
it definitely had me manually disable the warning that not emitting to a directory is deprecated
@magomimmo should I have faith that the tutorial is on the same page? Are we working towards file watching here? Is building to a target directory just step one of the master plan to teach me?
gosh. pretty much everything in this tutorial from a to zed is just broken on first pass. I think the first couple tutorials need to be deprecated in modern-cljs
ok, to be expected, depending on you setting. Make a tast in your build.boot with deftask. Last time I used boot (and this discussion may belong in #boot) this worked for me
(require
'[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
'[adzerk.boot-reload :refer [reload]]
'[pandeiro.boot-http :refer [serve]])
(deftask run []
(comp (serve)
(watch)
(cljs-repl)
(reload)
(cljs)))
(deftask development []
(task-options! cljs {:optimizations :none :source-map true}
reload {:on-jsload 'lambdawerk.app/init})
identity)
(deftask dev
"Simple alias to run application in development mode"
[]
(comp (development)
(run)))
then start boot with boot repl dev
hahaha, is there a quickstart quide you used? the problem is im working through a tutorial, and if I use that, I've kind of diverged from the process theyre showing me, at which point following the tutorial becomes of dubious value
never did this tutorial, I guess they are showing you different ways of developing and serving files. Look at some boot tutorials on github, should be more updated and skip the boot part in modern-cljs.
and maybe start with a terminal before using Cursive, then you know after getting control of the terminal how you want to configure Cursive (calling specific boot tasks etc). I know in cider this can be pain when you need to customize variables.
@idiomancy sorry to be late. May I suggest to submit an issue to modern-cljs? what's the issue you're dealing with? Take innto account that the seires has been written against boot 2.5.5.
@idiomancy any sigle tutorial has a branch. have you test them as follows? git checkout se-tutorial-01
or git checkout se-tutorial-2
@idiomancy I''be back at my night time (in 5 hours or more) hopefully the branch should work...
How could one make additional dependencies available in the Lumo REPL? I thought of just changing its build.boot
to include them and re-building; is there another way?
@pandeiro ideally you don't want to build a Lumo yourself 🙂
$ lumo -c /path/to/jar
cljs.user=> (require '[your.jar :as your.jar])
check out lumo -h
for all available command line options
@anmonteiro It would probably take me longer to figure out the classpath to the jars I want than to add specs to build.boot
and recompile 😉
yeah it is compiling node 🙂
lumo -c `boot show -d`
But my point is I would love to have a higher abstraction - like we're spoiled with, w/ boot and lein
^ that works
or
lumo -c `lein classpath`
oh boy
that sounds awesome!
I want to eventually add support for a socket REPL, so that it can be used out of the box with inf-clojure
or something
btw you can also: boot show -d > classpath.txt
and
lumo -c `cat classpath.txt`
^ this way you only incur in Boot's startup time once
anything that produces a colon separated string of paths can be passed to -c
or --classpath
(they're synonyms)
@pandeiro sorry it's boot show -c
, not -d
it's something to speed up require
ing namespaces
sometimes self-hosted ClojureScript takes a while to compile (it's like 1.5x slower than the JVM or something like that)
so if you start subsequent Lumo sessions with -k
or -K
the second time it just uses the cached compiled JS
btw all of these options are purposely the same as Planck
(to ease the learning curve)
while I don't get a documentation website online, this should help for the most part: http://planck-repl.org/
yeah, it's useful for -K
to be enabled in most cases
except for the namespaces you're actively developing, as it may mask some warnings and errors
(as it effectively skips compiling your source)
Makes sense, thanks. Most of what I want with this is something very fast for quick explorations, so I think I will set -K by default
Anyone know what I’m doing wrong here?
function removeProperty(obj, prop) {
if ( obj.hasOwnProperty(prop) ){
delete obj.prop;
return true;
} else {
return false;
}}
justtrying to remove the prop if its there and return true otherwise falseperfect thank you
Anyone suggest a good first tutorial or detailed guide to building your first Clojurescript app? I have seen many interesting tutorials but many seem to be out of date or require other knowledge (react, javascript, etc). I am looking for something that a group of us with basic Clojure experience can understand and successfully build something.
@jr0cket maybe this https://www.amazon.com/Web-Development-Clojure-Build-Bulletproof/dp/1937785645
@idiomancy I just tried the first two modern-cljs tutorials by checking out their branches (i.e. git checkout se-tutorial-01
and git checkout se-tutorial-02
) mentioned by you and they work as expected.
hey, I'm so sorry @magomimmo I got sidebarred by some other stuff and havent gotten to them. That's really good to hear but I didn't want you to have to sink a bunch of time into it.
@idiomancy non worry, it’s one minute test.