This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-17
Channels
- # admin-announcements (1)
- # aleph (1)
- # architecture (1)
- # bangalore-clj (14)
- # beginners (15)
- # boot (89)
- # braveandtrue (1)
- # cider (1)
- # cljs-dev (33)
- # cljsjs (1)
- # cljsrn (147)
- # clojure (149)
- # clojure-quebec (1)
- # clojure-russia (82)
- # clojure-spec (18)
- # clojure-taiwan (2)
- # clojure-uk (15)
- # clojurescript (97)
- # cursive (11)
- # datomic (22)
- # funcool (2)
- # hoplon (53)
- # immutant (16)
- # jobs-rus (8)
- # lambdaisland (1)
- # off-topic (13)
- # om (7)
- # onyx (58)
- # parinfer (6)
- # planck (19)
- # protorepl (2)
- # re-frame (17)
- # reagent (201)
- # rum (6)
- # specter (9)
- # test-check (68)
- # untangled (47)
- # yada (94)
So I want to make a clojurescript library that can eventually be used by JS programs. I've sat down and sketched out the idea and messed around a bit on a repl thinking it through and I am about to start coding. Is there a good example/lein template for starting out a project with the intention of making a cljs library vs the more general templates? I threw a couple queries at google but js interop and more generic lein examples are crowding out the search.
@bwstearns: I don’t think there’s a goto cljs template right now
mies was the standard for a while, but it shifted away from cljsbuild when cljs.jar became the quick start method. and now we have tenzing template for the boot, which is an alternative to lein
any of them will work, you just need to use ^:export
metadata on vars you want accessible from JS, or goog.exportSymbol
explicitly to customize the name
thanks @shaunlebron, I ended up just spinning up a figwheel lein project and I'll cut it down to the library when I've got something.
:thumbsup:
not sure how to search for it, so i would ask here: is there an equivalent of coffeescript's existential operator in clojurescript?
zip = lottery.drawWinner?().address?.zipcode
becomes
zip = typeof lottery.drawWinner === "function" ? (ref = lottery.drawWinner().address) != null ? ref.zipcode : void 0 : void 0;
i would hope to have something similar in clojurescript, so i wouldn't need to write for example
(when error (.-message error))
I remember a very useful function to convert objects into string representations that worked nicely with console.log. Does anybody know what might be the name of such function?
In clojurescript… it was something like pt-str
Darwin I'll try it later when I'm home, but the function I'm looking for was definitely a short name with two words it, such as pt-str.
Anyone know if there’s a way to make the clojurescript compiler fail on warnings?
Or at least return something other than 0
?
@chancerussell: yes - you can supply custom warning handlers
whats the status on spec/instrument
and spec/gen
? have they been ported over to clojurescript?
I tried using them but I couldn't get them to work, but it might've been because of my setup
@risto: Spec is at feature parity with Clojure as of 1.9.216
when I try to use (println (s/exercise-fn 'myfunc))
(' is backtick) I get java.lang.AssertionError : Assert failed: (symbol? sym)
@risto: created http://dev.clojure.org/jira/browse/CLJS-1757 for that
Is there any "framework" or library that lets me define a back-end end-point in my ClojureScript, such that I can call a Clojure function on it, and it'll locate the corresponding Clojure function in the back-end (via RPC or something), call it, and return the result, assuming it's just EDN?
In other words, is there something that lets me call a Clojure server from a ClojureScript front-end, as if it was in the same process, but only assuming EDN arguments and return values?
@sdegutis: never used it, but I think this looks like what you’re looking for? https://github.com/hoplon/castra
Is there a cljs nrepl client available?. Tried googling , but no luck.. There is one available as a node module though...
Does anyone know of a parser that transforms javascript into cljs code, using simple interop?
I run into this about once every few weeks, where I want to take a nodejs example and just run it as cljs. Usually doesn’t take long to manually transform it, but still… 🙂
my production javascript files are getting cached, anyone have an example on how to solve this, I understand you're suppose to add myfile.js?rel=x.y.z i was thinking of adding the md5 hash of the file, i'd like this to be automatic my lein build
(the issue is older versions of my SPA are loaded on clients browsers even when a new JS file is shipped to the server)
I wanted an nREPL client in Dirac DevTools, ended up running it on server-side and opening a websocket tunnel to it from client-side: https://github.com/binaryage/dirac/blob/417b81c3959e9b156f148f9448f2935f33631658/src/lib/dirac/lib/nrepl_tunnel.clj#L13-L47
@chancerussell: http://jakemccrary.com/blog/2015/12/19/clojurescript-treat-warnings-as-errors/
@timothypratley: Very interesting. Thank you!
is there a way to use clojure.test.check.clojure-test/defspec
with cljs.spec.test/check
?
@darwin: do you by any chance know if there’s anything lacking in https://developer.chrome.com/apps/sockets_tcp that would prevent me from implementing a proper nREPL client with it?
@sherbondy: no, it should be possible to use that api to implement real TCP connection to nREPL server
I needed it from a normal web app or extension, so this option wasn’t available for me
but maybe there is another option, to teach nREPL server another transport, e.g. websocket
that would require people running nREPL server to configure it and still you would have to implement clojure.tools.nrepl and bencode on client-side, which is a lot of work
maybe not bencode, I don’t remember exactly if it is part of transport protocol or not
ok, it is part of the transport, so you could use json or edn, when implementing websocket transport to make your life easier: https://github.com/clojure/tools.nrepl#transports-
Has anyone faced this issue with clojure.spec
in cljs?
clojure.lang.Compiler$CompilerException: java.lang.NoClassDefFoundError: com/google/common/base/Predicate, compiling:(cljs/closure.clj:1:1)
java.lang.NoClassDefFoundError: com/google/common/base/Predicate
java.lang.ClassNotFoundException: com.google.common.base.Predicate
...
cljs.closure/eval7975/loading--auto-- closure.clj: 9
cljs.closure/eval7975/invokeStatic closure.clj: 9
cljs.closure/eval7975 closure.clj: 9
@richiardiandrea: it does not look spec related
ok thanks David I will investigate more
I am saying spec because it coincided with me introducing it in the cljc
files but it might actually be something else
false alarm, I was excluding the guava
dependency in the project for some obscure reason
oh...it is tricky to spec a number in javascript (not an expert here)
(instance? js/Number 3) => false
@richiardiandrea: what’s wrong with cljs.core/number?
? 🙂
@anmonteiro: I guess nothing
just better 🙂
(I mean yours is better)
(s/def ::timestamp #?(:clj #(instance? Long %)
:cljs #(number? %)))
kind of ok for now ahah
@richiardiandrea: there’s also number?
in clojure
but can be float, double etc
it should actually be a long in clj
I think long?
exists
nope I don't see it, but today I am not seeing things 😉
yeah no it is not there
@richiardiandrea: I wonder where it went
hah! https://github.com/clojure/clojure/commit/20f67081b7654e44e960defb1e4e491c3a0c2c8b
I was going to quit for today but thankfully you saved my day 😄
I'll stick with the instance check but thanks for pointing that out
@dnolen: I came up with something, though it's a little quick and dirty: https://gist.github.com/Risto-Stevcev/dc628109abd840c7553de1c5d7d55608
though I've never used core.logic
yet, but I think it might be useful for that sort of thing
main utility for everyday programming seems to be when you have a bunch of conditions that need to be satisfied for some result, and when you don’t get that result you want to introspect why. with just functional programming not so easy, but with logic programming just assert the result and the set of conditions that are satisfied to get back the ones that aren't
yeah you get a little bit of that with :fn
in fdef
, but it doesn't handle situations where you want to prove that your program behaves a certain way when interacting with other functions (ie transitivity)