This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-12
Channels
- # admin-announcements (3)
- # announcements (1)
- # beginners (9)
- # boot (85)
- # bristol-clojurians (4)
- # cider (12)
- # cljs-dev (3)
- # clojure (91)
- # clojure-berlin (7)
- # clojure-dev (16)
- # clojure-italy (21)
- # clojure-russia (67)
- # clojure-spain (3)
- # clojure-uk (6)
- # clojurescript (139)
- # core-async (41)
- # cursive (7)
- # datomic (61)
- # editors (56)
- # events (16)
- # hoplon (11)
- # jobs (4)
- # ldnclj (14)
- # liberator (7)
- # off-topic (13)
- # om (5)
- # re-frame (22)
- # ring-swagger (27)
For those of us who want to experiment with the relay / om-next view of the world, what makes sense to start out with? Should we just follow the FB relay docs to get a feel for the architecture? Is there any CLJS stuff out there we can use to get the same architectural feel?
The falcor talks on youtube were helpful for me
Loading ClojureScript into Your iPhone http://blog.fikesfarm.com/posts/2015-08-11-loading-clojurescript-into-your-iphone.html
I don’t understand how to use js->clj with {:keywordize-keys true}. opts will be a sequence of rest args but the implementation destructures with :keys.
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L9326-L9327
ah, it works with (js->clj x :keywordize-keys true). Strange that the single arity call-site uses a map. https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L9325
Guys please tell me how I can convey with a backend, this cljs code (js/alert "xyz!")? so that I was able to compile and run in the browser
@a.espolov: sorry presumed you where hosting on nodejs
I'm getting a warning WARNING: cljs.core/bit-or, all arguments must be numbers, got [clj-nil number] instead.
from https://github.com/ztellman/automat/blob/007118e8f54e96381833db3f05db257f93f0119d/src/automat/fsm.cljx#L605 . Breaking that line into multiple lines shows it's from the (int end)
call. end
should never be nil
because it passes the number?
check, right? Why is this occurring? CC @dnolen
@domkm: numeric inference isn't quite that strong - number?
cannot help. However the int
coercion should cover it anyway. So probably just a bug.
@dnolen: Thanks. Is there a way to modify the code so that it can be inferred that it is a number?
@domkm: actually I don't really understand why you think the problem is here. I don't see bit-or
@dnolen: that's the line that cljs reports and when that line is split across multiple lines cljs reports the line with (int end)
@dnolen I think cljx maintains line numbers but I will verify when I get back to my computer. I assumed int used bit-or internally. I'll look into it more later. Thanks for your feedback.
@domkm: ah, I’d forgotten that int
was enhanced to inline expand to a bit-or
with 0. that’s the bug actually.
Are there any good suggestions for clojurescript logging libraries?
https://github.com/ptaoussanis/timbre this looks pretty nice but there might be better alternatives?
mitchelkuijpers: Shodan is worth checking out https://github.com/noprompt/shodan
@mitchelkuijpers: it’s pretty easy to roll your own using Closure logging stuff
@martinklepsch: Yeah I did that before but I think its better to choose on and then provide pull request if i miss any functionality
I am going with Shodan
I really like my Closure stuff 😄
Maybe you should open-source it 😉
I also use it a lot
you can pretty easily use their autocomplete stuff
I think a lot of people forget they have a lot of power from all the closure libs that just work
i wrote js apps with gclosure by hand for 8 months before i discovered clojure/script
it was a harrowing experience
but i did find a lot of great stuff in the library
@robert-stuttaford: yeah I combine it with Om or React but there are a lot of goodies in there
@robert-stuttaford: And very readible code
@mitchelkuijpers: https://gist.github.com/martinklepsch/b116442ad7f3b1f99fa1 — here it is 😄
@martinklepsch: I do like the combination for server and client, might have to reconsider
@mitchelkuijpers: probably easy to write a no-dependencies cljc logging lib from here on
@martinklepsch: true that
@martinklepsch: I might have to make a small lib from this gist if you don't mind
sure, it’s yours.
Awsum thnx
I'll credit you 😉
@mitchelkuijpers: ping me when it’s up
is this an acceptable way to make uuids on the client:
(defn uuid
[]
(letfn [(f [] (.toString (rand-int 16) 16))
(g [] (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 15))) 16))]
(.toString
(goog.string.StringBuffer.
(f) (f) (f) (f) (f) (f) (f) (f)
"-" (f) (f) (f) (f)
"-" "4" (f) (f) (f)
"-" (g) (f) (f) (f)
"-" (f) (f) (f) (f) (f) (f) (f) (f) (f) (f) (f) (f)))))
Now all I need is an awesome name for the lib
random-uuid
was recently added to CLJS @escherize, you might want to use that instead
@escherize: out of curiosity why do you need a uuid on the client?
i use it to keep track of some state (maps) that the client creates before sending up to the server
@escherize: I mostly use http://google.github.io/closure-library/api/class_goog_ui_IdGenerator.html
@crisptrutski: c for the readerconditional and then loggs?
@crisptrutski: I like the name 😄
kelloggs 😄
@martinklepsch: why use google’s logger instead of console.log?
Googles logger gives you the possibility to log to other stuff
like a server or a div
@robert-stuttaford: I haven’t fully explored the options there and logging to console seemed like the most intuitive thing — have you found something better than console logging?
i like the html div thing for mobile
querystring param enables in-page log, sort of thing
ah yeah, that’s nice
They have some built in appenders
probably there should some alternatives to log-to-console!
mitchelkuijpers: where can i find these appenders?
@robert-stuttaford: search for “setCapturing” here http://google.github.io/closure-library/api
http://google.github.io/closure-library/api/class_goog_debug_DebugWindow.html
these a are a few
pretty powerfull stuff
fantastic
feel the learn!
A new library is born: https://github.com/mitchelkuijpers/Cloggs
slog
would also have been a neat name
(Shameless self promotion): There is also: https://github.com/rauhs/klang
@mitchelkuijpers: My klang library was actually first based on the design ideas of goog.debug.DebugWindow
. Nowadays it's more powerful I think
i win the naming wars 😄
@rauh: klang is really nice, still want to use it in a project. It’s a lot more than a no-dependencies 50lines logging namespace though
@martinklepsch: Yes but none of that is going into production ever. I only use it through macros (which are included in klang)
There is a little section on how that's achieved ( https://github.com/rauhs/klang#with-deployment-to-clients )
Are there any examples out there of using CLJS to generate some JS for a page to do JQuery-style static page augmentation (i.e. updating some page elements on form element modification, client side validation etc)
I don’t want to go full-blown SPA but I’d like to use CLJS for the page scripting obviously
@cfleming: It might be possible to make that work, but ClojureScript was never designed for that kind of gradual enhancement with small snippets of code.
@stuartsierra: That’s a bummer. I guess it’s JQuery for me, I was hoping to avoid that.
@cfleming: @stuartsierra you can make little jq-like wrappers with goog.dom
etc.
@cfleming: @stuartsierra keep checking artifact size with each thing you add and make sure you don’t include/use stuff like persistent data structures etc — as far as I understand if you don’t use them they won’t be part of the build.
question then is though: will it be the same amount of fun? 😉
@martinklepsch: Hmm, that’s starting to sound like more complication than I was hoping for just to generate some small code snippets. I might just go with straight JS.
@cfleming: oh and there’s dommy of course
shodan is a pretty boring library. it's really just a thin layer over console
with a couple of extra helpers. i've been meaning to improve it (along with other work i've done) but i've been limited on free time (of which i'm now devoting to reading/learning rather than coding so much). there might be a chance for clojurescript at my day job in the near future so i might be able to squeeze in some improvements then but for now i'm relying on the hope that others will send me PRs.
i seldom use shodan because clairvoyant is typically what i need. for simple things i just use (.log js/console ...)
.
@martinklepsch: Thanks, dommy looks interesting, I’ll check that out. Looks like that should produce some pretty small JS too.
The nice thing about shodan is that it uses a macro, so tracebacks in the console link to your original source file where you invoked it rather than the place in cljs.core where (.log js/console)
is actually invoked when you use *enable-console-print!*
or whatever it’s called
@cfleming: you can easily use jQuery from cljs. What I have do is use jQuery and when I'm done take stock of what I used JQuery for. And then I replace the needed jQuery functionality, which is normally limited to a couple features.
@cfleming: the idea being not to let this stuff get in your way. You can easily tune after the fact.
cfleming: cljs + closure library is awesome for this use case — given the benefits of advanced compilation, you’ll probably end up with less JS in the end as well
the only real downside is having to learn cljs + closure library, but i don’t think that’s gonna be a problem for you
i did a static content site with history/secretary, custom form handling, ajax, etc — ~40K total gzip size
How does one debug macroexpansion in cljs? I'm getting a "WARNING: Use of undeclared Var seeitlater.main/G__7592 at line 10 src/seeitlater/main.cljs" and I suppose it is due to the fact my macro is expanded not as I expect. How do I see the expanded value?
@dottedmag: if you are not using cljs.js macro expansion is done in clojure, not clojurescript. the best way to see what is happening is to start a repl in the your macro namespace and use macroexpand-1
and macroexpand
@martinklepsch: nice post!
@bensu: Indeed, it was wrong macroexpansion. (.. foo bar (baz blah)) confused the macro which expected (baz blah) to be a function call.
..
is a macro itself and obeys all macroexpansion rules. you can also inspect what happens after ..
with macroexpand
@micha: thank you ❤️
To the React/Om/Reagent/Quiescent folks: I've been experimenting lately with the concept of 'pluggable component'. Here's a Reagent implementation of it, I would love some feedback: https://github.com/vvvvalvalval/reagent-pluggable-components-poc
Discussion in the Reagent Google Group: https://groups.google.com/forum/#!topic/reagent-project/zU2cpAwT29g
@val_waeselynck you are handling pub/sub from the parent to the child. another normal pattern is to "bubble" events up through channels as well. do you have any ideas to fit this in your model?
Yup you could totally extend this to EventTargets for example
another way I've considered is to have an ::async/pipe-up
recipe
Basically, you create a local chan that is piped to a chan passed by the parent, and closed when the child unmounts
yeah, that's the pattern I mean. great job, nobody (I mean the larger React ecosystem) has figured out how to structure components, local state, and events in a reasonable way.
(defmethod make-plug ::async/pipe-up [[_] parent-chan]
(let [local-chan (async/chan)]
(->Plug local-chan #(async/pipe local-chan parent-chan false) #(async/close! local-chan))))
This is still really questionable IMO. In a way, it's the management of your application state with the structure of your views.
But it's still interesting to see how we can leverage React's virtual dom to help us manage our state in a declarative way. Basically, I'm letting React's diffing algorithm and mount abstraction do the heavy lifting here