This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-08
Channels
- # admin-announcements (2)
- # beginners (35)
- # boot (353)
- # capetown (1)
- # cider (1)
- # cljs-dev (41)
- # cljsjs (3)
- # cljsrn (3)
- # clojure (118)
- # clojure-austin (12)
- # clojure-russia (17)
- # clojure-spec (21)
- # clojure-taiwan (1)
- # clojure-uk (91)
- # clojurescript (80)
- # clojurex (1)
- # cloverage (3)
- # datomic (66)
- # devcards (2)
- # events (2)
- # garden (6)
- # hoplon (54)
- # jobs-rus (1)
- # keechma (1)
- # lein-figwheel (4)
- # leiningen (3)
- # luminus (3)
- # off-topic (7)
- # om (4)
- # onyx (53)
- # other-languages (17)
- # proton (7)
- # protorepl (4)
- # re-frame (123)
- # reagent (1)
- # ring (6)
- # rum (2)
- # spacemacs (1)
- # specter (21)
- # testing (1)
- # untangled (1)
- # yada (42)
I'm new to clojure/ clojurescript and I'm building a web application . How do you compie the clojurescript files into a single js file with the relevant dependencies in production mode?
@isekream: Turn the optimization mode to :advanced
, see https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimizations. I’d recommend using lein-cljsbuild, which is a very useful plugin to get started, it makes doing stuff like this much easier
question if I used a framework e.g. React or Luminus does the framework get bundled into the JS file or do I still need to package the "output" directory with it?
@maxov: I'd recommend you to just use JavaScript interop for either d3 or any other d3-based JavaScript library.
@levitanong: That’s what I’m doing currently, was wondering if there was any better way. Thanks
@maxov: I know how you feel. I've been looking as well, but I'm guessing nobody wants to do it anymore because d3's mutations and the way it does things is so... Un-functional.
it seems like everybody is moving to use react, but I still really like d3’s declarative style… the enter/exit selections feel pretty nice, even if they are mutable
@delaguardo: Thanks for the suggestion (and sorry for coming back late). I tried all sorts of imaginable variations of what could be the correct keyword for catching the compositioned event, but still not having any luck. Do you know any snippets that listen to the compositioned event in the wild?
@maxov: are you using d3 to write to canvas? Since that is a problem that React doesn't really answer
If you're just using d3 to manipulate the DOM and don't like React, then maybe look at Hoplon. If you're not working on an SPA, Dommy is an option.
Anyway, don't feel like you need to give up d3 for react. What you're doing is exactly the thing that d3 was designed for, and what react wasn't designed for
d3 is pretty functional already, to be honest. I would love to see a clojurescript visualization library in the spirit of d3, or perhaps make one if I have the time
the only thing that came close was c2, but the developer deprecated it, suggesting react instead
I think also some of the "databinding" works for canvas, or at least it has some effort to make it closer to svg wrt event handling.
routing example with bidi And accountant 🙂 https://github.com/manishkumarmdb/bidi-routing-example
I came up with an idea and want to check it with you.
Some of my frequently dereferenced RAtom
s in Reagent
should always return a specific value if they are currently filled with an empty string. I want to define a new type which is extension of RAtom
and does all the functionalities same way as it except -deref
from IDeref
protocol which should return specific value (if (empty? @this) ...)
.
It looks to me like a standard problem which I would solve in OOP using class inheritance - I would make a new class by extending RAtom
and just override -deref
.
Does it even make sense in CLJS
and if it does how could be achieved?
@novakboskov: seems to me you can implement that in user land by defining a new protocol and extending the RAtom type to that protocol
(defprotocol UserDeref (user-deref [this]))
(extend-protocol UserDeref
RAtom
(user-deref [this]
(if (empty? @this) …))
default
(user-deref [this]
(-deref this)))
but then you’d need to use the user-deref
function everywhere, not sure if that’s desirable for you
@anmonteiro: Not all the RAtom
s should behave like this but only few of them, that's why I need a type for it, to make only that few RAtom
s of that type while rest remain the same.
Also, why you use user-deref
instead of -deref
? It seems to me that function overload by name works well:
(defprotocol IOld
(foo [this])
(bar [this]))
(deftype MyType [prop]
IOld
(foo [this] "Hello old.")
(bar [this] (.-prop this)))
(defprotocol IProt
(foo [tihis]))
(extend-protocol IProt
MyType
(foo [this] "Hello new!"))
(let [a (->MyType "type")]
[(foo a) (bar a)])
;; => ["Hello new!" "type"]
@novakboskov: just used a different function name as an example, to be easily distinguished
@novakboskov: Use a Reagent reaction?
(def x (r/atom 123))
(def y (reagent.ratom/reaction (or @x "foobar")))
@anmonteiro: Right. Actually, I know how to extend types through protocols but what I need is to make new type based on existed one - literally parent-child relationship from OOP.
@cursork: I can't find that reagent.ratom/reaction
function in Reagent 0.6.0-rc
...
is it possible in macro to understand if the optimization mode is :advanced
or :none
?
@asolovyov: (:optimizations (cljs.analyzer.api/get-options))
@anmonteiro: thanks!
@asolovyov: needless to say it needs to be called from Clojure
@asolovyov: curious why would you want that? seems like you are asking for trouble
and one of the problems for me right now is that I'm not sure how do you make it so... that modules are separate and loaded separately in production, but loaded all at once in development
what I'm doing right now is that I have two lists of modules - which I need to load in production and in development - and switch between them
I've looked at shadow-build-example few days ago and didn't notice anything about it there
(new to boot) I’ve just packaged up a JS lib for cljsjs and issued a PR. What do I need to do to deploy this to clojars under my own org name to use in the meantime?
looks like the key was getting it to read my leiningen gpg creds file by putting this into ~/.boot/profile.boot
: https://github.com/boot-clj/boot/wiki/Repository-Credentials-and-Deploying#lein-credentials-file
and then running boot package push --repo clojars