This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-24
Channels
- # announcements (2)
- # beginners (130)
- # calva (72)
- # cider (4)
- # cljdoc (15)
- # cljs-dev (3)
- # cljsrn (2)
- # clojars (4)
- # clojure (55)
- # clojure-nl (1)
- # clojure-uk (19)
- # clojurescript (46)
- # cursive (95)
- # datomic (6)
- # figwheel (40)
- # fulcro (12)
- # hyperfiddle (3)
- # off-topic (11)
- # onyx (3)
- # parinfer (6)
- # pathom (15)
- # protorepl (38)
- # re-frame (67)
- # reitit (18)
- # shadow-cljs (45)
- # tools-deps (2)
I didn't find any library to subscribe to GraphQL from cljs/Node (all of them either use only HTTP or asume you are in the browser), so came up with this, maybe someone finds it useful: https://gist.github.com/polymeris/d20a5a2aad02fa83f36ee0b57ed96496
any ideas how to get around https://dev.clojure.org/jira/browse/CLJ-1625? I wanted to have all protocols in one namespace[1], but that does not work when protocols happen to have same method names đ [1] https://github.com/binaryage/chromex/blob/master/src/lib/chromex/protocols.cljs
@darwin having the same name in the same ns is never gonna work. how would the user even distinguish what to call?
well Iâve never had deep thought about it, I was using protocols with this pattern, and never hit this problem with same names
I was thinking that protocol name is somehow involved in the lookup and it happens under the hood, e.g. chromex.protocols/subscribe!
is just a sugar for chromex.protocols/IChromePort:subscribe!
if not ambiguous
no, in case of non-unique names, youâd use full qualification with protocol name in it
the names are unique internally so you can have the same name from different namespaces
nevermind, now I know how it works, and I will have to put procotols into unique namespaces
well, I just have a convention how to translate API names into clojure protocol names, I just want it to be consistent
and even without this case, I might strongly want to âreuseâ nice names even if I were free to pick my own names
now I have a secondary problem, I decided to bit the bullet and move protocols into separate namespaces, but wanted to produced user-friendly error for someone using my lib and having code using old protocols, something nice with explanation where to find replacements
my first approach: I wanted to emit an error when someone requires chromex.protocols
, it worked, except in debug builds all cljs files are compiled, and that was triggering the error even if nothing was using the namespace
my second approach was to mark protocols somehow as âmovedâ, or forward them to proper places, didnât find a solution
(ns chromex.protocols) (defn subscribe! [target ...] (something.else/subscribe! target ...))
from the users perspective a protocol call looks just like a function call so you can swap them easily
thanks for the hints, I think this will be good solution, I will forward all existing protocol methods with a warning, and if someone used protocols for implementation they get some standard compiler warnings about missing protocols and will have to investigate it themselves
you don't always need to extra features defrecord
provides so deftype
is better for those cases
Also, stepping back a little, cljs.core
is really defining the fundamental implementation of types, where it is appropriate to use deftype
. There's a mini Twitter discussion on the subject here https://twitter.com/mfikes/status/1017840912855117825
Can anyone explain this difference, Clojure vs ClojureScript? With Clojure:
user=> (do (print ".") (print "."))
..nil
With ClojureScript (on NodeJS):
cljs.user=> (do (print ".") (print "."))
.
.
nil
On ClojureScript, where are the newlines coming from? I'm using print
not println
@alza-bitz Normally setting *print-newline*
to false
would be sufficient, but there may be some limitation to the shipping Node REPL.
$ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"}}}' -m cljs.main --repl-env node -e '(do (print ".") (print ".") (prn *print-newline*))'
.
.
false
with-out-str
works as expected. Can be something with JVM<>Node
~ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"}}}' -m cljs.main --repl-env node -e '(prn (with-out-str (do (print ".") (print ".") (prn *print-newline*))))'
"..true\n"
@alza-bitz it is printed using console.log
which always adds a newline