This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-04
Channels
- # beginners (25)
- # boot (14)
- # business (1)
- # cljsrn (2)
- # clojure (180)
- # clojure-korea (14)
- # clojure-russia (8)
- # clojure-spec (9)
- # clojure-uk (17)
- # clojurescript (110)
- # cursive (14)
- # datomic (18)
- # emacs (23)
- # events (4)
- # garden (7)
- # hoplon (44)
- # lein-figwheel (1)
- # liberator (4)
- # london-clojurians (1)
- # om (10)
- # om-next (2)
- # onyx (22)
- # protorepl (60)
- # re-frame (36)
- # reagent (11)
- # ring (10)
- # yada (5)
Do you guys have some guidance to share on creating a javascript file that can be imported as a module from clojurescript?
@Isenta https://github.com/clojure/clojurescript/wiki/Packaging-Foreign-Dependencies https://github.com/clojure/clojurescript/wiki/dependencies
@keymone if you really want a framework (as in 'battery included'), I'd look at Re-frame, Om Next and Hoplon. But be aware that since we have Google Closure Library in ClojureScript, a framework is somewhat less appealing than in JavaScript.
seconding val, I'd suggest going with plain reagent first and then moving on to a state mgmt framework like re-frame only if you actually need it
Rum is cool too as a React wrapper.
i do need routing and state management, i’m just a bit out of the loop so don’t know what’s the new “hotness” 🙂
that's the thing, you may get away with just a simple r/atom initially
only decide on something more involved once you feel the pain
(agree that rum is a good alternative)
@keymone untangled is also a good option
ok.. what kind of trouble you usually run into using just something simple like reagent but something like re-frame handles better?
I woud not say re-frame is not "less simple" than reagent, it just deals with issues that Reagent doesn't
Reagent is about views, re-frame is about state management
yeah i know in redux there's this action / reducer separation but in reagent you mostly directly change the state of the app atom.. im just not familiar what kind of benefits this separation gives you.. it is more complex for sure
@sammikko best way to know is to start w/ Reagent only, problems will show up soon enough 🙂
or they won't, in which case it was a good idea to use Reagent only
yeah i figured.. thats why i asked what are the first things that you usually stumble on 🙂
always a good idea to read the re-frame manifesto
like.. if you need to do xxx, you should probably pick re-frame instead of just reagent
you'll learn a lot even if you don't end up using the library per se
@sammikko: I gave a talk at the conj on re-frame, it might give you a better idea of what it's like. There's also the #re-frame channel if you have questions about specifics - there are a few teams who have built very large apps with re-frame and they might be able to give you some ideas on what benefits they see as apps grow.
@lsenta you could write a Closure Module, this you can then use like you use Closure libraries
@lsenta here's a simplistic example, there are more JS files in this repo as well with more complex modules: https://github.com/uxbox/uxbox/blob/master/frontend/src/uxbox/util/uuid_impl.js
@shaun-mahood cool thanks.. is the video available somewhere? couldnt find it with a quick google
The doc around the :libs
tag and the uuid example unblocked me, thanks a lot @martinklepsch & @hlolli
@lsenta you don't need :libs
if you adhere to maven naming/namespace conventions I believe
(just so you know 🙂)
I'm writing a Medium post about going from React to ClojureScript. Does anyone have some good tutorials for beginners getting into cljs, figwheel and reframe?
@puppybits modern-cljs builds on Boot so there's no Figwheel there. IMO still a good setup 🙂
aem...working on it :)
I've looked into boot but not used it yet. Does it give the same browser based live coding setup that figwheel has?
@richiardiandrea is your work only about porting the cljs bits or also the clojure stuff?
Yesterday on the plane back from the conj I was able to send the correct kind of messages for reloading modified js files...still need some polishing though
@martinklepsch only the figwheel client/UI at the moment
Cool, always seemed like it would be very hard to make the clj code work nicely with Boot
Boot-reload provides the trigger and I send the messages, well I tried to hammer figwheel in boot-figwheel but my results where poor, I have heard it is kind of possible to see it working, but I wanted to have it "the boot way", with immutable file system and all
So the only way was keeping everything as it is (and Juho agreed), plugging the client for better visuals and see if the boot-cljs can be improved independently from figwheel
@puppybits I made a template https://github.com/martinklepsch/tenzing that you can give a try to see what the boot setup is like
The thing I like about figwheel for first time users is it given them a browser with live coding and warning messages from a single command. It's a really easy entry point. It really sounds like boot is the future. I'm wondering if it's as easy for a frontend JS dev who is already biased against a lisp.
@puppybits I'd suggest to give it a try and see for yourself. With tenzing you can have something running in <5min
As a clojure(script) diletante, I moved my lein+figwheel project to boot a few days ago, it makes much more sense to me
I work with a lot of dev who are against React cause of JSX syntax and Angular devs who have a hard time looking outside of Angular.
If they can understand why its better they tend to get past the fact that it's a lisp and can move onto better tools.
For this case I usually send people to the reframe template, you got testing live reload and reframe
yep i think that's a good starting point. It's less different than what they already know.
you don’t have to learn the whole reframe machinery since you have all the reagent features already
@puppybits not really, the reframe homepage covered it all
super light would be the reagent homepage (http://reagent-project.github.io/)
@puppybits Not really a tutorial, but if someone prefers to jump straight into the code then https://github.com/Day8/re-frame/blob/master/examples/simple/src/simpleexample/core.cljs is a pretty nice and simple illustration of how re-frame works
Definitely agree with @lsenta that the reagent homepage is a very good starting point, though
@martinklepsch can you tell me more about the maven naming convention?
I’m pretty sure I follow the usual naming, I got my frontend/components/doughnut_impl.js
which goog.provide(”frontend.components.doughnut_impl”)
Am I missing something? from your advice and the project you've linked I’m under the impression it should work.
boot cljs compiler gives me ERROR: Invalid :refer, var frontend.components.doughnut-impl/render does not exists in file <the_caller>.cljs
@lsenta more of a guess but try a namespace that doesn't have a _
question
if you do the build.clj style like:
(require 'cljs.build.api)
(cljs.build.api/build "src"
{:main '<%= nameHyphened %>.core
:output-to “dist/cljs/main.js”})
that then requires java -cp lib/cljs.jar:src clojure.main scripts/build.clj
, would that pull and use dependencies in the project root’s project.clj?trying to figure out how to fit cljsjs packages into this proj i’m on
@martinklepsch It’s working now, lots of reorganising and rewriting, not sure what was wrong. Thanks again for answering another maven-related question I had 🙂
@pvinis the simplest way is just a little above, and also described in here: https://github.com/clojure/clojurescript/wiki/Quick-Start#clojurescript-compiler Then there are a lot of other ways that involve project/dependencies/hot reload, the wiki is pretty rich
i saw that, but yea, goog is missing, and i dont want to have html stuff. is there a super simple way so i have one cljs file, compile it to js, and run is with node file.js
@pvinis mmm...the above setup is a one line command + a build.clj
file...did you have any error in particular? The cljs compiler uses the Google Closure compiler for the conversion
@pvinis there is always going to be at least a call to goog
as it has been chosen for handling modules, but it should be transparent to you
everything should be already taken care of
@pvinis so to better answer your question, if you have limitations in including goog/base.js
in your final js then no, it is not going to work without it
yes you can, make sure you serve the out
folder
https://github.com/clojure/clojurescript/wiki/Quick-Start#google-closure-library
in the out dir i have a cljs dir, a goog dir, a hello-world dir and a couple of js files
ah ok, now i see, sorry you are compiling node
you need a compiler option
https://github.com/clojure/clojurescript/wiki/Quick-Start#running-clojurescript-on-nodejs
as I said, the wiki is good 🙂
(node does not define js/document
among other things so ClojureScript needs to adapt the code it generates)
no probz! glad it helped!