This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-26
Channels
- # admin-announcements (1)
- # beginners (12)
- # cider (2)
- # cljs-dev (6)
- # cljsrn (4)
- # clojure (123)
- # clojure-austin (10)
- # clojure-brasil (1)
- # clojure-canada (21)
- # clojure-conj (5)
- # clojure-dev (8)
- # clojure-gamedev (42)
- # clojure-russia (121)
- # clojure-sanfrancisco (2)
- # clojure-spec (25)
- # clojure-uk (36)
- # clojurescript (195)
- # clojutre (3)
- # cursive (43)
- # datomic (6)
- # defnpodcast (2)
- # dirac (14)
- # emacs (2)
- # ethereum (2)
- # events (2)
- # funcool (6)
- # hoplon (76)
- # jobs (1)
- # kekkonen (9)
- # lein-figwheel (1)
- # leiningen (4)
- # mount (6)
- # off-topic (5)
- # om (2)
- # onyx (91)
- # pedestal (2)
- # protorepl (14)
- # re-frame (22)
- # reagent (20)
- # rethinkdb (1)
- # ring (2)
- # schema (3)
- # sfcljs (3)
- # spacemacs (15)
- # specter (12)
- # testing (1)
- # yada (63)
After getting (cljsjs) react infinite to work, I wonder what would be benefitial using a react library for infinite scrolling versus just use cljs(closure event fns) to detect scrolling events and on designated point, fetch the needed data (say for a table) and concatenate it in a for loop?
@hlolli i guess it depends on how well that library does the infinite scrolling, and what features of it you use. if you heavily use the library, there is nothing wrong with keeping it. but, if its just for a small component, it could be better to do it yourself. weigh the two up 🙂
this comes down a bit to what involves in infinite scrolling, read a stackoverflow reply from 2012 that the facebook infinite scrolling only stopped after 500Mbs were added to the memory trough firefox. Seems to me now when scrolling the newsfeed, that the elements are redisplayed. What im working on now is only text in a table, I think that I will just concatinate the text at certain points, and yes, just inject them into the memory of the user, except anyone knows of any trick to free the dom and reinsert them when scrolling up. The method Im thinking about would probably involve slow scrollup in case of long scrolldown.
and scrollspy, sounds like some tool I could use for this. Guessing doing a core.async event loop would slow things down a bit, but Im not sure.
Hi all. Why does this macro throw a null-pointer exception during compilation? (defmacro ident [x] (var-get (ns-resolve *ns* x)))
@nickt: var-get
is not in clojurescript that I can see
@shaunlebron dang...
I'm trying to write a macro that would inline the value of a constant variable during the cljs -> js stage
is that not what ~foo
does? I rarely write macros
something like....
(def my-class
(.createClass js/React #js
{:displayName (macros/ident constants/modal)
...}))
getting compiled to
React.createClass({
displayName: "someConstantModalRelatedString"
})
as opposed to
React.createClass({
displayName: hello_world.constants.modal
})
:displayName constants/modal
would not be evaluated to that?
ah, I see
(defmacro ident [x]
`~x)
lol I’m spitballingso var-get
is getting the value at a var
@shaunlebron definitely open to ideas, I'll keep trying it out 😛
in cljs, (deref #’foo)
will get you the value at foo
in sort of a roundabout way
@shaunlebron does that work at compile-tiem?
i’ll have to check the IDeref implementation for cljs vars
(defn ns-resolve
"Given a namespace and a symbol return the corresponding var analysis map.
Analagous to clojure.core/ns-resolve but returns var analysis map not Var.”
https://github.com/clojure/clojurescript/blob/7a06d008fadf56b11dba0f9e2ab97e61059f44fc/src/main/clojure/cljs/analyzer/api.cljc#L196-L199@nickt: ns-resolve does not give you a var even
I'd like to include a file in my build that's not in the dependency graph of requires. I think that when using cljsbuild, the :main
ns in the :compiler
map is the root namespace and everything it leads to is built into the program. Can I add another namespace to the build somehow without having main require it?
FWIW, I'd like to include tests in the emitted JS to aid in automated regression testing.
@shaunlebron ah bummer
if ns-resolve
gives you an analysis map of a constant, you might find the value in there. it might just be a matter of inspecting that map and finding the right key
same, I’m making some progress in test project, just poking around
@nickt: analysis map does not have a value "{:name test.core/foo, :file \"src/test/core.cljs\", :line 5, :column 1, :end-line 5, :end-column 9, :meta {:file \"/Users/swilliam/cljs-inline/src/test/core.cljs\", :line 5, :column 6, :end-line 5, :end-column 9}}”
@shaunlebron hmm....
Dang... I feel like the compiler should have some way of identifying that this is a constant value
i’ll look at how the constant is emitted
@shaunlebron so in the repl, (deref #'hello_world.constants/blue)
@nickt: didn’t follow the discussion from the beginning but I have done some “constant folding” at compile-time with macros
if the code passed into macros can be eval’d at compile-time, you can just feed it into eval, or provide some boilerplate around, it is not a general technique, I have used it for concatenating CSS into single strings just to produce more optimized sources 🙂
look at my css
macro here: https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/defaults.cljs#L226
https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/defaults.clj#L104-L114
here is the trick: https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/defaults.clj#L81-L86
in my “sublanguage” I allow all clojure.core functions and my own devtools.defaults macros, as long as the body of css macro can be eval’d as this restricted clojure code, I can fold it at compile-time
for example you thinking that you can use js-interop inside css macro, you can’t because the code there is clojure core
@alpheus if you want that file to appear consistently in your build you must require it
ohhhh interesting, maybe the issue I've been having is that my constants are in cljs not in clj
or using any other clojure function/macro in your project which is not exposed to the eval
@dnolen that's what I thought; since it's a test and requires the main namespace, it causes circular dependencies. So this may just be a bad idea.
@nickt: not sure what is your goal, but you have eval
only in clojure (via compile-time macro), you cannot feed it with cljs code
@darwin but if my constants are defined in a cljc
file, then I can eval
them at compile-time in something like your css
macro, but also reference them at runtime if I need dynamic calculations in my javascript, right?
this is pretty tricky topic, you can have constants defined in a clojure file, you can decide to “emit” their results as (evaluated) cljs variables
eval
is needed if you are passed some “unknown” code from user of your macro and you want to emit another “code”
in my css
case, user of css macro gives me arbitrary code-like data structure, it happens to be evaluate-able by my eval function, so I eval it and then return concatenated string to be emitted in original place
the values of vars simply don’t seem available at compile-time to cljs macros
Macros are quite dense thing to learn, for me initially was very confusing and blurry the distinction between clojure (macros) and clojurescript (normal code). Because I came from Javascript lands, not from Java lands. So I happened to be first exposed to clojurescript and then when I started messing with macros with the whole Clojure/Java side which is a different thing on this level - it helps to understand how clojurescript compiler is implemented first. I would recommend this book: https://pragprog.com/book/cjclojure/mastering-clojure-macros
I traced (defmethod parse ‘def
all the way to emit
, and the constant expression isn't persisted anywhere for use at compile-time
@nickt: this is what I mean by “emit”: https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/preload.cljs#L11 https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/preload.clj#L9
(at compile time) macro gets some data (which may be code) and emits some (other) data which happens to be code
dang maybe I gotta really put some time into this... I'll be back in a bit, gotta do some work-related work 😛
@darwin: nice, I didn’t know you could put arbitrary data in compiler options and retrieve them at compile-time like that: (get-in @cljs.env/*compiler* [:options :external-config :devtools/config])
@shaunlebron yeah, it is a gem, discovered it just recently thanks to @bhauman
you should use :external-config
to prevent warnings from figwheel validations, freshly written it could look like this:
https://github.com/binaryage/dirac/blob/master/src/runtime/dirac/runtime/preload.clj
@alpheus if you’re making a test build than just make :main
the test ns to avoid that circularity right?
That makes sense and I tried just that but when I ran the tests from the browser none were exercised. That's probably a different problem but I thought I'd better ask here, in case there was a well-known way of doing this.
@alpheus tests don’t automatically run, you need to invoke them via cljs.test/run-tests
there’s tooling out there to run them for you which is why you might not know you need to do this
@alpheus so try run-tests
on a particularly ns then to determine if there’s a bug or something here
That may solve my problem, but out of curiosity, how does the cljs.user namespace make it into the JS, and is there a way to add more there?
is there an idiomatic way to invoke a fn that is a key inside a map? for example, it feels awk to do ((:some-fn my-map))
hmm, okay, if that’s idiomatic its fine with me. personal taste says it reads easier when scanning to be something like (call :some-fn my-map)
@lwhorton sure but you can write that yourself, it’s not so common a pattern that anything needs to be done about it
I would probably use get
in that case to make it more readable
although maybe that’s not any better since it doesn’t remove the double parens
do others find it difficult to spec functions that use core-async for backend comms? This seems where stubbing would be very helpful, that is to stub out backend service calls. However since core-async based functions only return channels, not request responses...how do other people tackle this issue?
@lwhorton: I only like primitives in the call position of a list, e.g.:
(let [some-fn (:some-fn my-map)]
(some-fn))
or even:
(let [{:keys [some-fn]} my-map]
(some-fn))
I want to build a little clojurescript library but I don’t know how to get started. Can someone point me to a simple example with tests and a repl?
hi guys, do we have any "videos training" on clojurescript? Do we have any clojurescript in Pluralsight?
@erlis: There's some good content at both https://purelyfunctional.tv/ and https://lambdaisland.com/, both are actively producing content. Pluralsight has some Clojure content but it is pretty old, and no ClojureScript content that I am aware of. Safari books have a few pieces of ClojureScript video content, but I've not watched any of it.
Also, @ericnormand (http://purelyfunctional.tv) and @plexus (lambda island) are both great if you have questions about any of their content.
Are you looking specifically for video, or would good written content help as well? There are lots of good ClojureScript specific resources available now, so if you have specific interests I'm sure someone here can recommend something.
I was watching @ericnormand with some of the free content. I was aware of the purely http://functional.tv site
Yeah, it's not been active for long, but it's very reasonably priced and the content is excellent of the videos I've watched.
I was also following https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition
Adam Abramov (creator of Redux) one guy, created tons of material so your start is easy
@erlis: Is there a particular area you're having trouble with? I've found the available ClojureScript content is generally very good once you find it, but it can be difficult to find if you don't know where to look. I've heard the same comment from others who have previously worked with React + Redux, so it may be that their documentation is just that much better.
if you google Redux Videos http://lmgtfy.com/?q=redux+videos
That's awesome that it exists. The React and Redux community is definitely much larger than the ClojureScript community, so I'm not too surprised.
I've found good material in clojurescript, the videos bring another dimension to the learning experience. You can see how people are using it, specially the more advanced users
Oh wow, that's really impressive then
I'm not saying anything about the size of the community, I've been trying to use clojureScript for a while and I've learning from tons of resources (good work out there) I was just comparing my personal experience while learning something new like Redux
@shaun-mahood’s suggestions are probably the best
Not sure about others, but I find it way easier to learn from written or interactive content than video so it's not really bothered me.
based on Dan’s Twitter statements doing that kind of thing is also a good way to burnout
I wish I have only 0.0001 the knowledge on clojurescript you have Nolen so I can do something for others... I'll keep learning though. Thanks for listening...
that will be great, in the meantime I'll check some content there for clojure. I was just surprised clojurescript is not listed
@erlis: If you're interested in helping improve the situation I think we would all welcome it - I just noticed there's a bunch of video content listed on http://clojure.org/community/resources that hasn't been added to http://clojurescript.org/community/resources yet. I also think it would be safe to say that most of the community would be receptive to ideas to help the learning experience.
@erlis they have asked me several time but I don’t have time for it- I’m not sure how it works so maybe they want somebody that’s known in the community or something
most sure they want the very first course to be from someone known to promote it. But usually they have regular people that are "presenters" and they do this type of stuff, I love the coursed presented by Scott Allen known for his website Odetocode
don't know if any of those guys knows anything about Clojurescript, probably not. And probably that's why they are asking you
well if somebody else’s wants to actually do it and have me put a stamp on it I’d be happy to oblige
maybe that's something you can tell Pluralsight if they contact you again. Also this is not free, they should pay for this
@erlis: Pluralsight authors get paid for sure, it looks like the really popular ones actually make a very good living.
this can be a good incentive to someone from the community to put some content and see what happens, @dnolen said it can help with the material.
@shaun-mahood yes it seems like a pretty good deal for the content authors
few years ago Pluralsight was BS, but they have been buying some of the best sites and authors and now their content is top notch
well, I think they bought everyone 🙂 just googled pluralsight adquires
and you will see
@erlis: http://purelyfunctional.tv is also looking for content authors - I don't think it's an issue of demand as much as the fact that video just takes so much effort - for a current example, the untangled videos are pretty recent and really good but I believe there are already portions of them that need updating. I can't imagine the amount of time it would take to keep up with some of the fast moving changes in the Clojure world, it's hard enough to do with text based documentation.
@shaun-mahood thanks for the resources I'll take a look for what's there.
@dnolen It definitely would be an interesting project. Since atoms are watchable, you can use them in almost the same way as Redux
I think you would need at least a lightweight reducer though because it rely's on foldp
doesn’t om.next provide you “time/traveling” almost out of the box? or I’m confusing it with something else?
@ag I'm thinking more of something generic and reusable, like an instrument function that records history across changes in the atom
@ag it gives you the structure for it but none of the helper stuff that might be useful
so I wrote a macro that references another namespace admin.core/app in the generated code, except when I compile my clojurescript it says admin.core/app is undeclared var by every cjls file that uses this macro I wrote. Any way for the macro definition to specify dependencies of the generated code?
@jasonjckn: I would like to know as well, but I’m afraid it is not possible
I tend to use same name for clj and cljs namespace (even empty) and in cljs namespace I add all dependencies possibly used by macro-generated code. In macros I then use fully-qualified names to dependent code (not aliases). And at macro call sites I tend to require macros via cljs namespace, which then implicitly brings dependencies along. Make sense?