This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-02
Channels
- # aleph (5)
- # beginners (112)
- # boot (137)
- # cider (10)
- # cljs-dev (36)
- # cljsrn (2)
- # clojure (118)
- # clojure-argentina (1)
- # clojure-berlin (1)
- # clojure-brasil (3)
- # clojure-dev (4)
- # clojure-italy (2)
- # clojure-nl (13)
- # clojure-russia (23)
- # clojure-spec (5)
- # clojure-uk (53)
- # clojurescript (344)
- # clojutre (1)
- # core-async (65)
- # cursive (9)
- # datascript (7)
- # datomic (28)
- # devops (1)
- # emacs (16)
- # events (1)
- # jobs (5)
- # keechma (18)
- # lumo (56)
- # off-topic (7)
- # om (3)
- # onyx (14)
- # protorepl (21)
- # re-frame (3)
- # reagent (20)
- # ring (12)
- # ring-swagger (9)
- # specter (17)
- # unrepl (14)
- # vim (14)
- # yada (22)
yes you can, so if you want to be cool and avoid the intermediate string, do this
cljs.user=> (binding [cljs.core/print-fn js/console.log] (cljs.pprint/pprint {:a 1})) {:a 1} nil
(console.log is an example, also beware of the asterisks...)
@joelsanchez: if you do (enable-console-print!)
it will also do the same thing as your example above
#om Some om help would be greatly appreciated. I just cloned the repo and am trying to run through an example.
I have navigate to
/om/examples/hello
just tried to run the following:
lein cljsbuild once hello
And I get the following errors.
clojure.lang.ExceptionInfo: failed compiling file:examples/hello/out/cljs/pprint.cljs {:file #object[java.io.File 0x7dae9ff4 "examples/hello/out/cljs/pprint.cljs"]}
...
Caused by: clojure.lang.ExceptionInfo: Invalid :refer, macro cljs.pprint/deftype does not exist in file examples/hello/out/cljs/pprint.cljs {:tag :cljs/analysis-error}
...
Does anyone know how to get pprint working?
@ssaul I don’t know the exact issue but you should run the lein
from the project root, not the /om/examples/hello
folder
I’m looking for some examples of how to organise and load cljs that’s compiled using closure modules, as described in David Nolen’s 2015 post: http://swannodette.github.io/2015/02/23/hello-google-closure-modules/
@lsnape what do you want to know? the :modules
support in core still has some issues but I can fill in the details if you have particular questions?
@thheller I’m really after some guidelines on how to lazily load the javascript from within the clojurescript. i.e. how I bake that logic into my existing code.
https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#module-loader
that’s how it would work in shadow-cljs
… core doesn’t have the :module-loader
stuff so you’d have to roll your own
The guide I tried to find was hosted on http://rasterize.io, but the server is down and I can’t find a cached version anywhere 😞
I’m surprised at the dearth of community resources around code splitting. Seems to me like the only sensible way of getting a large compiled JS file down to a reasonable size.
ie. this page http://www.smartchecker.de/tarifvergleich/smartphone loads 3 javascript files
while this http://www.smartchecker.de/ only uses one because it doesn’t need to calc stuff
found that using <link as="script" href="/assets/smartchecker/js/common.94FA12F00A1477825565E742BB62B0D8.js" rel="preload">
provided a much faster experience than using async loading
https://w3c.github.io/preload/ it may become a standard though
Well I’m keen to have a go at it myself. Google’s Lighthouse report flagged that the size of the js and stylesheets need to come down: https://writeandimprove.com/workbooks
There are a few other things we could do, but modules seems like the only way to go if we want to stay a SPA!
nice site but yeah the chrome coverage thing shows that 70% of the code is unused when I just load the page
there's also a nice high-level wrapper around localStorage: https://funcool.github.io/hodgepodge/
What is a simples way to try new fast cljs builds without forking clojurescript, i.e. some snapshot releases?
@nicola If you just want to try: Copy the contents of cljs.compiler
in a .cljc
file in your project. It'll get picked up before the one in the cljs jar. But don't forget to remove it at some point! 🙂
That's also usually the way I use when I hack on some libraries, easier than putting it in checkouts
How can I require all the namespaces of my application in cljs? It seems that explicit :requiring is needed (in contrast with CLJ)
(for example, multimethods: in clj they just work, in cljs I need to require every namespace that extends a multimethod)
I was doing this: https://gist.github.com/JoelSanchez/5a799b8f1bf5bfb42b1fbf44827b2899
This requires all namespaces that begin with "ventas.pages" (they extend a multimethod elsewhere)
@theheller. I tried that original and I think I got some others error. When I get on my computer I will try it and post that error. Thanks.
@joelsanchez by far the best and easiest way is to just write it down manually
@thheller That's what I'm doing now, was just wondering
I was thinking that maybe I could require those namespaces using the Google Closure api or something
But I'll stick with manual require for now
FWIW I think build tools can help with that as well … but really the manual way is the most reliable and just works
having problems extending cljs.core/IRecord
:
(defprotocol Foo (foo [o]))
(extend-protocol Foo cljs.core/IRecord (foo [o] (println "hi")))
(defrecord R [])
(def r (->R))
(foo r) ;; throws exception
the equivalent in clojure with clojure.lang.IRecord works fine
is this a bug in cljs or intended behavior?
ok, thanks
so there's no way to get a protocol to apply to all records?
also, what's the purpose of cljs.core/IRecord?
extending the Object works (at least in Lumo): (extend-protocol Foo js/Object (foo [o] (println "hi")))
@nathanmarz you can add a default case and catch records there
good point, i'll do that
@dnolen I'm pretty newb with the protocol stuff. Am I to understand that extending js/Object
should be done with caution? Is that mostly because of the lack of Clojure namespacing on the JS side?
Ah, rgr. Thanks. If I absolutely have to use js/Object
though... what does it mean that I'm mutating the fundamental prototype? Am I potentially clobbering other possible foo
s on js/Object
?
it will definitely lead to disaster under advanced compilation as your protocol extensions will get munged into a one or two characters
Has anyone here used the :npm-deps
feature alongside lein and figwheel?
@liesbeth @elisabeth you sound like you have Dutch names. Feel free to check out #clojure-nl
In response to myself... I searched the Slack channel for :npm-deps
and found a comment that suggested I needed to do npm init
. Tru dat.
I have designed one HTML form with J's validation..Which redirected to next webpage My question is how do I print all data coming in form in next page
@omkar It's not clear to me exactly what you're asking for. Are you asking how to access the data from the previous page's form?
Gotcha. Did you submit the form to a server?
Generally, that's what you do. Submit form -> server -> server does a redirect -> server serves up the original data into the next page.
If you're using an SPA, things are different.
Are you writing an SPA?
I think running npm init
should only be necessary if you already have a parent directory with a package.json
/`node_modules` (node will try to install to that parent directory)
@rgdelato Well, dang. I just checked and there was a node_modules directory sitting way up near the root. That should never have been there.
@omkar You can do it just with HTML, CSS, and JavaScript. I can think of two ways.
One is to not actually do a "form post" at all, but to capture the data and redraw the screen (e.g. using some client-side templating or React or whatever).
The other is to do a "GET" instead of a "POST', and to pull the form values out of the URL in the next screen.
@rgdelato Thanks, by the way!
Hm. That's a very broad question.
Have you ever done a form post before with any server stack? (e.g. with Rails or PHP or whatever?)
Ah. OK. Hm.
What exactly are you trying to do? What is your application for?
I have no clear idea. I am creating webpages one by one to learn things. Now I think to make it as project
^^^ I was just going to ask that. 🙂
I think what you need to do is follow a basic intro to web-development tutorial.
What programming language are you most comfortable with (if any)?
You've done Angular 1 before? How did you handle forms in NG1?
Anyway, if Java is what you're most comfy with, I think I'd start here: https://playframework.com/
See if you can find a good step-by-step tutorial on how to build applications using that framework (or another Java framework).
I'm not familiar with the Java world, but last I checked, that seemed to be the framework I'd likely use if I had to use Java.
I come from a C#, Node, Ruby background, and only know bits and pieces of Java because I like Clojure.
Clojure?
That's the language this Slack channel is concerned with.
See, I want to learn HTTP interaction .I have created great webpage it has 5 inputs. Name age ...Etc Now on next page I want to print it from server
@omkar you might want to try these examples: http://www.luminusweb.net/docs
There are other more "SPA" oriented, all ClojureScript frameworks out there you can check out too when you're ready.
Right. I'd agree with John's advice if you're interested in learning Clojure. But it sounds like maybe you're not (and maybe you're in the wrong place for advice!) But what I'd recommend based on everything you've said is to start with a step-by-step tutorial on how to build a web application. You cn do it with luminus as John suggested or with Rails (they have excellent tutorials) or with Play (and that'd keep you in Java land, which it sounds like you're comfortable with).
That Luminous example is complex, but it'll introduce you to a large number of pieces of a stack that you could actually find in production in the wild.
For an SPA, re-com looks interesting for building forms: https://github.com/Day8/re-com
For simple inputs though, in an SPA, I'd forgo any form
HTML element altogether and simply listen for events on whatever kind of input element and then work with the values in the data that the element feeds into the event handler. Perhaps store it in an atom. Then when the next page renders, have it pull data from that atom.
I just realized that with schema lib, the schema.test/validate-schemas
fixture doesn’t seem to be appropriate for cljs.test
style fixtures (it takes the test fn to run). I’m not seeing any clear examples online of how to do it in cljs either
@mikerod how is it not compatible? a fixture takes a test as a function then calls it
you can use comp to use it inside your own fixture (or manually compose) if you need other fixture functionality
oh wait - cljs.test - how is that different/
I am now realizing I haven’t used fixtures in cljs…
they are different due to its ability to also deal with async tests (I take it from the docs)
(cljs.test/use-fixtures :once
{:before (fn [] (schema.core/with-fn-validation! true))
:after (fn [] (schema.core/with-fn-validation! false))})
However, I found it odd that the schema.test
ns compiles on the cljs side to something not useful and with incorrect docs
Also, the approach I said above isn’t great since it is a global change and you aren’t sure it was “false” before the test
So probably would have to get the “original value” of that flag to reset back to in the :after
it seems an odd design choice not to allow wrapping the test form in your own parent form
odd - this really looks like it would expect functions and not a hash-map
dev:kingfisher.core=> (clojure.repl/source t/use-fixtures)
(defmacro use-fixtures [type & fns]
(condp = type
:once
`(def ~'cljs-test-once-fixtures
[~@fns])
:each
`(def ~'cljs-test-each-fixtures
[~@fns])
:else
(throw
(#?(:clj Exception. :cljs js/Error.) "First argument to cljs.test/use-fixtures must be :once or :each"))))
The Google Closure Library is just weird sometimes in their design choices. The InputDatePicker doesn’t update the widget when the widget is open and you type in a correct date that is different from the one chosen by the widget
@mikerod https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/test.cljs#L201
quoting:
Instead of a map, a fixture can be specified like this:
(defn my-fixture [f]
Perform setup, establish bindings, whatever.
(f) Then call the function we were passed.
Tear-down / clean-up code here.
)
so it supports the clojure.test style - or so it claims at least
it just can’t do that with async - which is too bad
Oh interesting. I'll have to try. The main cljs site should mention that too. But if it works good.
@adamvh Interesting. I haven't checked out Untangled. Have you looked at re-frame? Looks like untangled uses om-next which seemed more complicated than re-frame when I (briefly) looked at it.
tried to learn re-frame, om-next, untangled, and found them all "too structured" for my needs
i don't know javascript or really much about the browser at all, so opinionated monoliths like untangled are more up my alley
I like re-frame from what I've seen. I've done some pretty complex front-end apps (in Angular, Vue, and most recently in React). I feel like just using reagent will quickly mean a messy app.
"it's a thing wrapper over react + js" is less of a selling point for someone who doesn't know javascript 😛
re-frame is amazing, but I don't know what your client-server interaction requirements are
https://reagent-project.github.io/ is where I learned reagent
@chrisdavies : the problem I ran into re-frame .... is that it's sorta db like, and at that point, I really want a full featured db, like datascript, rather than re-frame
om-next is really complicated, though. especially because the literature associated with it is sort of vague about what exactly it is and is for
@qqq You can use a full-featured DB as the datastore if you want. re-frame is about atomistic state changes, which you don't get out of Vanilla reagant
@captainlexington : not to play devil's advocate; genuine question: at that point, why do I need re-frame ?
@qqq I haven't used DataScript - I am not sure of the scope of their transactions. What would it look like to put attach a DataScript transaction to, say, the on-click of a button
?
in plain reagent, when the button is presssed, some function, usually :on-click is triggered right?
Well, that does seem pretty straightforward. You could be right! Without understanding DataScript I sort of worry about what the code starts to look like at scale - is there an obvious place to look when I wonder why an action is producing a certain result? How many points of failure are there when an extended interaction doesn't work as expected?
re-frame locks you into only worrying about events and subscriptions
You can lock yourself in with your own patterns for that, but then the question becomes why not re-frame, at least to me
Although it looks like using DataScript as the store for a re-frame DB is not as trivial as I thought it would be, so perhaps I shouldn't be opining at all 😄
@captainlexington with regards to: > Although it looks like using DataScript as the store for a re-frame DB is not as trivial as I thought it would be, so perhaps I shouldn’t be opining at all https://github.com/Day8/re-frame/issues/137 is a hot topic that relates I believe From the last post there https://github.com/Day8/re-frame/issues/137#issuecomment-302089561 there is an example fork that, I believe, shows that it can use datascript (maybe) https://github.com/chpill/re-frankenstein/ It is proof-of-concept I think to try to solve the issue
Some of this was concerning local state vs global, but from what I gather, it can apply more broadly to just managing your state elsewhere (even if it is still single-app-state)
@mikerod Yeah! These are all interesting. I also found https://github.com/mpdairy/posh , which implies there is at least something extra you need to do to marry DataScript to reagent
Marry them in a sustainable way, I mean - and the sustainable marriage between data and UI is what I ❤️ about re-frame
So really all the advice boils down to (if whoever we were giving this unsolicited advice to is still paying attention) is "probably don't use just reagent by itself"
I think if the state interactions are not too complex reagent
can be an alright starting point, but as you scale out, you’ll probably start to feel the pain
and then learn of the 50 different libs and millions of blog posts out there about managing state
:thumbsup:
yeah, I think a bunch of us have been through this
From what I have experienced at least, I do think the transition from a reagent
only app to re-frame
could actually go somewhat smoothly
if you were already starting to have some sort of controls over your state you were manually managing
I was also initially attracted to Untangled, too, but haven't looked at it since it was pre-beta
Yeah, I’m not cutting down the om-next side at all. I just haven’t had much experience there.
and I shared @adamvh 's confusion about what om-next was all about
And I haven't had to work on a full stack app since ^_^
going pretty far with reagent (and no helper libs) made me realize what the point of om-next was
“reagent: training wheels for om-next”
i was like where's the freakin date-picker widget in this thing? but then i realize that it's basically just a much smarter version of something like qt's signals and slots
Ok, I guess this is the first time I’ve attempted to use schema with cljs, but it doesn’t look like schema.core/defn
works?
I see no indication that it wouldn’t, but also no examples where it is actually used out there
where ufv
is a local generated by the macro that is a flag to know if validation is to be on/off at runtime
I feel like something must jsut be wrong. Pretty sure I’ve seen schema.core/defn
work in cljs before
That big state ball, while immutable, can still be hairy to update. Specter comes in handy there.
Isn't re-frame, with the subscriptions, pretty much providing a lensing mechanism over that state atom?
Hi, does anyone have good tutorial or lein template covering Planck + Lein + Reframe + Emacs? I’m having problems configuring this… thanks in advance for any url or tip how to do that.
@pawel.kapala Planck + Lein is covered somewhat in http://planck-repl.org/dependencies.html Planck + Emacs is covered in http://planck-repl.org/ides.html Reframe—hmm, I know Om Next can do something with self-host https://anmonteiro.com/2016/08/om-next-and-bootstrapped-clojurescript/ but I haven't delved into that world. You want all four of those things to work together? You're crazy 😝
@mfikes thanks! so far I’ve managed to use re-frame with devcards on custom template, but I’d love to use Planck, sounds like I need to write blog post when I manage to do that 🙂 And yeah, spacemacs rocks, it would be rather hard for me to use something else 😉
@pawel.kapala Yes, please to the blog post, if you get it working.
I know it's probably controversial, but I'm not a Java guy (C#, JavaScript, Ruby). I'd love to be able to do real Clojure without JVM.
@mfikes not sure, this looks promising though: https://github.com/Day8/re-frame/pull/325
I don't think it's controversial not to like the JVM. I think usually ClojureScript and even Clojure for Mono (which has a real name that I don't remember) are pretty close to 'real' though
Any flaws with using ClojureScript for non-FED projects are more to do with the shortcomings of JS than CLJS
I’m just curious as I’m just getting my legs underneath me with reagent and re-frame, but what is the allure of rum over reagent?
Corollary: Is the emphasis and support for pure ClojureScript just people’s annoyance with the JVM, or for some more systematic reason (like keeping everything pure JS, with interop between front- and back-end libraries)?
I think the purpose of self-hosting ClojureScript is that it's easier to get people to try it that way (at least, that's why I value it)
Like, self-hosting ClojureScript could run entirely in a broweser
You could have an entire IDE for it as a browser extension
How's the situation for "native Clojure"? Last time I checked there was no good solution
Though why you’d want that over the JVM I don’t really know, outside of some insane performance edge cases.
And even then, how could you really optimize for it?
I guess some people just don't like the JVM as a production runtime
I've heard things about security flaws and what have you
I like the JVM, but it would be good to have small binaries that start instantly
For example if I want to rewrite Openbox in Clojure, JVM is not an option
I can't use Clojure for everything, 'cause of that
clojure-scheme belongs to the category of "last updated 20 years ago"
Still good to know
@joelsanchez maybe this someday https://github.com/pixie-lang/pixie
pixie is great, but it’s not nearly as performant as jvm clojure
Know about pixie, author said this: "Some other developers have commit rights and have pushed it along a bit, but I think it's somewhat a language looking for usecase."
I translate that as "not going to maintain this"
it takes about a second less to start up and the vm is built into the binary though
FWIW, some of the rationale for self-hosted ClojureScript is documented here: https://github.com/clojure/clojurescript/wiki/Bootstrapped-ClojureScript-FAQ#why-was-bootstrapped-clojurescript-created-then
Guess I could use one of the unmaintained / outdated options if I wanted to, for example, rewrite Openbox
Configuring (and extending) my userspace with clojure would be awesome
pixie is fun - it makes it easy to do interop with c libs (or at least easier than it is from jvm clojure) - but the effort/reward probably isn’t there for doing anything interesting
Will give it a try then, there's also ferret but it is also abandoned
Not abandoned at all, okay: https://github.com/nakkaya/ferret
But I don't like it a lot
@joelsanchez One thing you can do is use ClojureScript to drive native code.
node.js?
@joelsanchez wait, is it just me or is that a repo with no source code?
That, or even a binary of your own making. For example, I did that to make an iOS binary. https://github.com/mfikes/goby
Not just you...and I don't know how to compile ferret anyway...and the source code, I do not know where it is
@joelsanchez If you can get CLJS working on gnome extensions, which apparently run js, then you could probably build a window manager with CLJS.
Planck is really just the ClojureScript runtime and a bunch of C, and the C can do anything, really.
eyah, planck on linux already uses the gnome js engine right?
oh, I must be misremembering
I could have sworn I had to install a bunch of gnome-dev-js stuff to build it
Interesting. Here's the list of build-time deps: https://github.com/mfikes/planck/wiki/Building
aha! that clears it up then
ferret is not abandoned, https://github.com/nakkaya/ferret/graphs/contributors
Yes I saw that, still I do not know how to compile it
Author says: "The latest sources are available at,", and then points to the repo that has no code
I will try cljs with the methods mentioned here
he is using emacs + org mode, that is pretty hard pre-requisite for new contributors 😞
Try spacemacs if you haven't already
I wonder if you can use Craig's stuff as a starting point if you wanted to build a native executable with Node. https://clojurescript.org/guides/native-executables António obviously went farther with Lumo.
oh - so the source code is all inside org mode babel? lol
Obviously what follows now is developing an API for building desktop components, then link that to React, and then use reagent to control that
The natural conclusion
@joelsanchez Definitely: http://blog.fikesfarm.com/posts/2015-11-19-clojurescript-react-native-desktop.html
Can't believe it.
It's not even an insane conclusion. Most desktop UI toolkits sucks.
I hate JavaScript as a runtime but I love how it interacts with HTML
Damn it, the thing is for macOS
well, “recently” is actually “a year ago”: https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
btw. on the screenshot in the article, there is no memory tab, but I can confirm that latest canary + node v8.0.0 has support for it and it will appear there
Yeah I found the memory tab, no graph like jvisualvm but good enough to have an idea
web-based editors. i don't need a full structured (xml-ish) editor, just something that allows users to mark phrases for special treatment, e.g. various kinds of highlighting. anything like that available in a cljs lib?
For node js debugging, it's great to see the Chrome/V8 team is actively supporting it. Cool stuff from I/O conference here https://youtu.be/EdFDJANJJLs?t=26m17s
New weird issue. When I am trying to make a uberjar with leiningen that includes all compiled js (via cljsbuild) it works if I have something like
:output-to "resources/public/js/app.js"
but if I try to put this one directory lower
:output-to "resources/public/js/out/app.js"
It doesn’t include the app.js
. It actually doesn’t include the resources/public/js/out
dir at all.