This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-05
Channels
- # aleph (2)
- # beginners (93)
- # boot (9)
- # cider (1)
- # cljs-dev (50)
- # cljsrn (4)
- # clojure (32)
- # clojure-russia (58)
- # clojure-spec (23)
- # clojurescript (146)
- # clojurewerkz (2)
- # component (1)
- # cursive (2)
- # hoplon (163)
- # off-topic (4)
- # om (117)
- # onyx (8)
- # pedestal (1)
- # re-frame (13)
- # reagent (34)
- # spacemacs (17)
- # test-check (1)
- # untangled (3)
is it okay to ask reagent questions in here? the specific channel looks quite dead and not just because it's saturday
i suppose in case anyone stumbles in, i'm coming from a background of using react just with the top-level API instead of JSX and looking for example projects along those lines to help me wrap my head around porting components, i.e. less nested markup and more mapping sequences to UI element properties. particularly any that make use of react.createFactory to create many instances of the same UI elements would be very useful
@sophiago same boat here. I’ve been able to defer the need for Om/Reagent and am just doing vanilla react in clojure (global state stored in an atom). It’s working so far
I’ve got a top level container component, and am using function arity as my Props
: https://github.com/amirrajan/mokepon/blob/gh-pages/src/mokepon/container.cljs#L223
here are some views that resemble react components: https://github.com/amirrajan/mokepon/tree/gh-pages/src/mokepon/views
@amirrajan glad you popped in! someone came around in #reagent but seems to have no idea how react works...
i looked at the reagent api and obviously it can do what i need, but was concerned i'd have to slog through the source all alone to make sense of just porting a simple component
yea, coming from the JS world into CLJS is a bit foreign, but so far I’ve been logging all my stuff in this repo
specifically this section that acts as almost a rosetta stone betwen es6/JSX -> clojure/sabono: https://github.com/amirrajan/mokepon#es2015-classes--jsx-vs-clojure-functions--sablono
and finally, this was another hurdle, but I got it working: https://github.com/amirrajan/mokepon/blob/gh-pages/src/mokepon/elements.cljs#L15
and just using idioms I learned from vanilla react (flux/one way events haven’t been explored yet because a top level atom has been sufficient, but time will tell if that is good enought)
so essential, top level containers, passing everything down to sub components via “props”, and holding all the state in an atom/top level swap events
yes, seems like you're halfway in between in that you use js for all the react stuff yet atoms for your state
i was hoping to have nice cljs wrappers for my react classes...except at least with some example projects to go off of!
yep, I used fluxible for a year (yahoo’s flux framework), but wasn’t a fan of their state persistence/propagation
sablono is pretty great, and then you can do what i did in elements.cljs
if you need to go against the metal and roll your own stuff
any feedback welcome of course, just exploring myself and seeing what I find by coming at it with JS/React glasses on
yeah see i'm not sure i'd even run into those problems going that route since, again, i never saw the point of using JSX
(never saw the point myself, top level dsl-ish functions felt sufficient for me too, which is why I started gravitating to cljs and the hiccup formatting)
so the elements.cljs file has a sample of how to create a class right against react, you may be able to just use that bit of code and interop directly with React’s api (and use a top level atom)
i'm confused about what soblono is (i have someone knew coming on in #reagent...still seems to have not used react much talking about how great hiccup is)
Aside: this line is important btw: https://github.com/amirrajan/mokepon/blob/gh-pages/src/mokepon/container.cljs#L292
Here is one of my react/js repos (my style): https://github.com/amirrajan/agilitree/blob/master/client/agile-tree-container.jsx
here's a one component example if you can put up with if being mixed in with the html... https://github.com/Sophia-Gold/dancing-sliders/blob/master/index.html
ah perfect, so that would be this in clojure: https://github.com/amirrajan/mokepon/blob/gh-pages/src/mokepon/elements.cljs#L21
and the usage: https://github.com/amirrajan/mokepon/blob/gh-pages/src/mokepon/components.cljs#L145
(again, this is all my own terrible concoction and can use any help/feedback I can get)
you say "that would be this in clojure" and then link some js interop that creates an animation element
i mean i asked a question when i came on here and it wasn't, "reagent has no tutorials on how to create markup elements?!"
as opposed to having mutations everywhere (I know react stops a bit of that with props/ImmutableJS)
i would like to actually like react wrappers for clojurescript, which exist there just aren't examples for them since they're not intended for use...just as a backend for hiccup
and also everyone is ignoring the complexity of the (extremely short) example here as if that isn't the point of not using hiccup
the huge value add for me (with regards to reagent, et al) will probably be how they handle event propagation/state change
yeah, not sure if you really looked at that like 50 lines of js code...you move a slider you get 100s of more sliders generated in the diff
@sophiago if you're very familiar with React you may get something out of reading the Rum sources: https://github.com/tonsky/rum
didn't follow the full conversation but it sounds like you'd like to better understand how to interact with plain React from ClojureScript? If you feel like it feel free to restate your question and I'll try answering 🙂
hi! is there a library or established snippet how to adapt JS promises to core async?
@martinklepsch one sec, reading up 🙂
@martinklepsch the readme is a bit confusing, but also intriguing. i gather what you're getting at is as opposed to how reagent wraps most of the react api, rum just provides mixins for the various lifecycle functions as well as providing direct access to React.Component in cljs?
so if i'm understanding that correctly i guess i'd then have to debate both the feature set it covers and performance compared to reagent, although it seems it may be the same in both and just simpler in my use case. it would seem both cover about the full range of the api minus some syntactic sugar (like createFactory...which I do use, but whatever) and i believe reagant's claim of speedup based on automating lifecycle management, but also that i likely wouldn't benefit from it much. but it would seem the rum's syntax is much more straightforward for those working with the api, plus although it's a smaller community the size of the codebase could be a benefit (i'm exploring this potentially to build a suite of charting tools for a client that would need to be highly stable and easy to maintain...selling him on clojurescript in general would really be wrapped up in selling him on me and i'd likely benchmark the hell out of whatever i mock up compared to what he's doing with d3 + typescript right now)
@martinklepsch: how does rum compare to sabolono? Same ideas?
Son maybe a better question would be how it compares to Quiescent. And sorry for not reading your sample code throughly (getting car serviced)
I need to read up on Rum see if that gives me a good middle ground between roll my own and reagent. Hope convincing your boss goes well
and like i said, i don't think i need to convince him of tech as long as i convince him of me
one of the way of doing so possibly being showing him benchmarks that are through the roof. i respect that he codes (and far more than trivially as well for a finance guy), but i definitely have the upper hand discussing things in that he doesn't get some stuff. but discussion isn't worth much. and nor is code samples in a language he doesn't know well. i'd rather show him irrefutable numbers
i also have very little dataviz background...he approached me because of a lot of graphics stuff i've done in addition to frontend. so i'd ideally like to benchmark something that makes use of some type of charting library and i've seen several used with reagent at least
idk if there's also the possibility of just building something myself out of just react UI components and core.matrix?
ok... so realistically i shouldn't have jumped into reagant and should try and use today to do a comparison between my options
quiescent seems quite appealing from a glance...they seem to have a factory example??
so now i'm mainly going back and comparing quiescent and om...the latter having the main advantage of wide support
why do I get a warning when I extend js/Object
?
am I supposed to provide a default impl to a protocol some other way, like having wrapper functions that check satisfies?
?
@gfredericks doesn't extending object
work for you?
that's probably what I was missing
@gfredericks you'll get the warning with js/String
, js/Function
and all that stuff
but you have the lower-cased special versions that you can safely extend
e.g.
(extend-type string
IFoo
(foo [this] :foo))
is object
enough for strings and functions or do I need to do each one?
I would only know by trying, but my hunch is that you need to do each one
object
string
function
and nil
is exhaustive, or are there more?
number
?
array
too, probably
¯\(ツ)/¯
this is starting to sound repetitive
@gfredericks extending js/Object
is probably what you want but it might result in a small perf hit
well thanks, this seems to be working
except for number
oh scratch that
everything is fine.
Hey guys, just being curious here. Will clojurescript have a compiler written in js some day?
it sort of does; but I think the biggest impediment to that being first class is the use of the google closure compiler, which runs on the jvm
is cljs.spec keeping up with clojure.spec?
or should I assume cross-platform specs won't be feasible for a while?
as a longtime js dev i'm much happier with the the current clojurescript compiler than any i could possibly imagine ever written in js
it's written in clojure so that means fast prototyping, easy interop with backend and contrib libraries
i actually have major issues when it comes to writing libraries for clj, but there are issues with doing the same for that due to speed on the jvm
well I’m also a js dev, and the only thing I don’t like about Clojure is that I have to use Java every now and then.
so if you know clojure you can write cljs libraries, patch the compiler, etc. without knowing js
@gfredericks Ha, that’s good to know. I heard closure compiler is great, however I really don’t like it as part of the dev build process. I hope somehow we can abstract it out.
@markx the JavaScript that the ClojureScript compiler is compatible with the Google Closure Library
you may choose to pass it through the Closure Compiler or not
but the Closure Library stuff is a hard requirement, and can't be turned off