This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-19
Channels
- # adventofcode (82)
- # beginners (70)
- # boot (34)
- # boot-dev (13)
- # cider (45)
- # clara (4)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (91)
- # clojure-art (8)
- # clojure-czech (1)
- # clojure-dusseldorf (3)
- # clojure-france (11)
- # clojure-germany (1)
- # clojure-greece (39)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-norway (2)
- # clojure-spec (7)
- # clojure-uk (31)
- # clojurescript (56)
- # core-async (7)
- # cursive (8)
- # data-science (10)
- # datomic (41)
- # duct (7)
- # emacs (1)
- # events (1)
- # fulcro (83)
- # graphql (6)
- # klipse (1)
- # leiningen (28)
- # lumo (67)
- # off-topic (14)
- # om (9)
- # onyx (3)
- # perun (4)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (2)
- # rum (1)
- # specter (46)
- # sql (13)
- # uncomplicate (17)
- # unrepl (114)
any alternative to this pattern (new (type {}) 1)
where you construct a new type based on the return value of type?
(deftype MyType [val])
(def a (new MyType 1))
(new (type a) 2)
=> cljs.core.type.call is not a constructor@hlolli, for collections, you can use empty
ahhh ok! I see now what IEmptyableCollection
is for. thanks @smith.adriane
An interesting example of that is if you compare (empty (first {:a 1}))
in ClojureScript and Clojure.
Perhaps this may lead to things changing some day: https://dev.clojure.org/jira/browse/CLJS-2013
Does anyone use cljs-devtools? The docs say that I should enable customer formatters in Chrome but I don’t see that option in Chrome 63.
Maybe they are now on by default, or moved elsewhere in the ui?
I still see the option in Ch 63 (OS X) - dev tools settings - Preferences - section Console
I must be looking at the wrong thing. I’m clicking on the gear in the console tab of devtools.
As mentioned in the other thread that is indeed wrong :)
my current dev setup is: client side: cljs + boot-reload server side: jvm + clj + nrepl + cider I am considering changing server side to: nodejs + cljs + ... is there still a way to get a repl here ? I have heard lumo/planck mentioned a bit. Does anyone have a working setup I can copy/paste ? @seancorfield @tbaldridge [ moved to #clojurescript ]
I did brew install lumo
and did lumo
and I have a repl
but I guess, what's the point of moving away from the jvm?
$ lumo
Lumo 1.1.0
ClojureScript 1.9.456
Docs: (doc function-name-here)
Exit: Control+D or :cljs/quit or exit
cljs.user=>
hmm, I have a repl now too 🙂I've got a baffling question related to using spec in clojurescript. I've got the following code:
(defprotocol parse-dates
(parse-date [date] "Convert date to formatted string")
(parse-datetime [date] "Convert date-time to formatted string")
(parse-date-at-time [date] "Convert date-time to formatted string w/ word 'at' between date and time"))
(s/fdef parse-date
:args (s/cat :date (s/alt :string :webtools.spec.dates/date-str
:date-time :webtools.spec.dates/date
:nil :webtools.spec.core/nil))
:ret :webtools.spec.dates/date)
(s/fdef parse-datetime
:args (s/cat :date-time (s/alt :string :webtools.spec.dates/date-time-str
:date-time :webtools.spec.dates/date
:nil :webtools.spec.core/nil))
:ret :webtools.spec.dates/date)
(s/fdef parse-date-at-time
:args (s/cat :date-at-time (s/or :string :webtools.spec.dates/date-at-time-str
:date-time :webtools.spec.dates/date
:nil :webtools.spec.core/nil))
:ret :webtools.spec.dates/date)
#?(:clj
(extend-protocol parse-dates
java.lang.String
(parse-date [date] (format/parse const/date-formatter date))
(parse-datetime [date] (format/parse const/date-time-formatter date))
(parse-date-at-time [date] (format/parse const/date-at-time-formatter date))
org.joda.time.DateTime
(parse-date [date] date)
(parse-datetime [date] date)
(parse-date-at-time [date] date)
nil
(parse-date [date] nil)
(parse-datetime [date] nil)
(parse-date-at-time [date] nil))
:cljs
(extend-protocol parse-dates
string
(parse-date [date] (format/parse const/date-formatter date))
(parse-datetime [date] (format/parse const/date-time-formatter date))
(parse-date-at-time [date]
(-> (clojure.string/replace date #"at" "") ;; Workaround for bug in cljs-time handling of 'at'
(clojure.string/replace #"\s+" " ")
(parse-datetime)))
function
(parse-date [date] date)
(parse-datetime [date] date)
(parse-date-at-time [date] date)
object
(parse-date [date] date)
(parse-datetime [date] date)
(parse-date-at-time [date] date)
nil
(parse-date [date] nil)
(parse-datetime [date] nil)
(parse-date-at-time [date] nil)))
If I comment out the specs, it works. If I leave the specs in (which work correctly in Clojure), it dies and gives me cryptic error messages that are no help.
Any ideas what's wrong with the specs?
Hey, I’m trying to use a JS lib that makes heavy use of promise chaining. What’s the best, most cljs way of using a library like that? I’m fairly new, but I assume core.async is the recommended tool?
@mv core.async
doesn’t use promises. native interop is just fine, don’t need a library
core.async has promise-chans
I know, but we were talking about “trying to use a JS lib that makes heavy use of promise chaining” which promise-chans do not interface with. they act promise like but are still channels.
I’m trying to find examples of promises, but everything keeps pointing me to Promesa. Adding another lib doesn’t seem necessary
.then
just takes one function arg for “resolve” and another for “reject” if you want it
async await is also just syntax sugar for promises. core.async would be that sugar for CLJS but no not for promises themselves.
there was a discussion about async/await recently. I posted this example https://clojureverse.org/t/any-syntax-to-match-async-await-in-creating-web-servers/825/18?u=thheller
@thheller see also: http://funcool.github.io/promesa/latest/#async-await-syntax
I’m using core.async most of the time and very rarely native promise interop when I have to. Never needed promesa but I am aware of it.
i'm the other way around - lots of promises with a touch of core.async for operations on streams of values
Please let me know if it is inappropriate but eould like to share an article I have written about an experience that demonstrated to me, and hopefully also to others, the productivity gains one can get from ClojureScript compared to JavaScript. Feedback welcome, and feel free to share! http://techblog.telia.no/blog/experience-awesome-productivity-with-clojurescript-s-repl/
@tjscollins I’m assuming you can narrow what you’re trying so you don’t see a bunch of failures and only the ones that matter?
Thanks!
Also not sure if this is appropriate to share it here: turns out that CLJS is approximately three times smaller (LoC) vs Elm when implementing the same app https://medium.freecodecamp.org/a-real-world-comparison-of-front-end-frameworks-with-benchmarks-e1cb62fd526c. Once again thanks to @danielcompton for the re-frame implementation.
@U8A5NMMGD FYI the link to “CLJS re-frame” in that article just links to the github homepage
thanks @U8ES68TGX just corrected that
Good afternoon! I'm trying to adapt https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules to actually render in the browser. However, if I modify the :require
stanza here:
(ns example.core
(:require [react :refer [createElement]]
["react-dom/server" :as ReactDOMServer :refer [renderToString]]))
and change "react-dom/server" to "react-dom", I get: java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react-dom"
Is this known behavior? Is there some way around it?java -cp cljs.jar:src clojure.main build.clj
No lein or other abstractions that might make which version I'm using unclear.And the example as given does work, it renders to a string in the console. It's just that I'm not able to modify it to require "react-dom" instead of "react-dom/server"
@smw have you tried changing it to react-dom
without the string? perhaps it only accepts those strings that would be illegal as args to require
What’s an idiom to invoke an npm-aligned module like https://github.com/iamdustan/smoothscroll ? note that the intended call path is require('smoothscroll-polyfill').polyfill();
(although I could call window.__forceSmoothScrollPolyfill__ = true;
if I stage that statement before the require)