This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # architecture (13)
- # bangalore-clj (1)
- # beginners (174)
- # boot (25)
- # cider (65)
- # cljs-dev (10)
- # cljsjs (4)
- # cljsrn (3)
- # clojure (169)
- # clojure-berlin (27)
- # clojure-brasil (32)
- # clojure-greece (3)
- # clojure-russia (31)
- # clojure-sg (4)
- # clojure-spec (6)
- # clojure-uk (74)
- # clojurescript (186)
- # code-reviews (5)
- # css (12)
- # cursive (17)
- # datascript (1)
- # datomic (45)
- # dirac (33)
- # funcool (42)
- # hoplon (25)
- # jobs (6)
- # jobs-discuss (114)
- # lambdaisland (6)
- # leiningen (1)
- # luminus (24)
- # off-topic (86)
- # om (13)
- # om-next (14)
- # onyx (75)
- # perun (2)
- # protorepl (19)
- # re-frame (2)
- # reagent (17)
- # ring-swagger (2)
- # rum (1)
- # slack-help (2)
- # specter (31)
- # test-check (5)
- # timbre (1)
- # untangled (34)
- # vim (8)
http://stackoverflow.com/questions/4690758/splitting-a-clojure-namespace-over-multiple-files <-- does this only work in clojure and not in cljs ?
@tbaldridge: I got it working with clj, but cljc also compiles at cljs, and that's the problem I'm running into 🙂
so I don't like large files, as I find them difficult to navigate due to my editing habits (no fault of the editor)
I really like the SO structure of how core.clj works -- on enamespace, across multiple files
Then I gotta say, change your editing habits. Multi thousand line files are pretty standard in Clojure. Look no further than spec for examples
that's pretty insane, I like small modules of 50-200 lines; it's just unfortunate clj's support for "import from this and export this" isn't as nice as I'd like it to be
Computers are great at searching files. That kind of what I'm getting at. A great way to edit lisp is to navigate via definitions where it doesn't matter where forms are in a file.
1. I've never been in a situation where a logical unit is > 300 LOC 2. tbaldridge: well, if they're not in one logical unit, why should they be in the same namespace? 3. qqq: I don't have a good response. 4. tbaldridge: checkmate
I guess they should be in separate modules, and I just need better require/import management.
cljs blocks :refer-all; if I have multiple files that share common linew inside of (:require ... ), is there a way to def a variable there and not repeat myselv in every namespace ?
@qqq no, what I'm saying is, a logical unit of code should not be constrained by 300LOC. Let's do a quick survey of some Clojure core namespaces. clojure.core.async - 1.1k loc clojure.spec - 1.9k loc clojure.core.logic - 2.8k loc clojure.core.match - 2.1k loc clojure.test.check.generators - 1.5k loc
@qqq so I say, break apart namespaces where someone is likely to want A but not B. Aside from that, just stick it all in one place. It really is easier that way.
@tbaldridge: https://github.com/halgari/odin/blob/master/src/com/tbaldridge/odin.clj <-- I understand that odin was created for educational purposes to go with your videos; in a "production environment", would odin be 1 single file instead of 4 files that are 100-400 lines long ?
that's a great question. There I mostly broke it apart based on a public API and private API (stuff in unification.clj is not public). And from there based on if you'd want A vs B. So you can choose not to import the Datomic bits if you don't need them
And also Odin doesn't have a hard dependency on several libraries. For example you don't need Datomic as a project dependency if you never require the
context.datomic namespace. Same for
re: your earlier point: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj <-- I never realized clojure.core was a single file with 7k+ lines
alright; so I guess . should be doing "largest reasonable unit" rather than "refactor into smallest reasonable unit"; then I should get better at emacs to manage going through files that are thousands of lines long
I think separating into multiple files prematurely gives a false sense of tidiness.
Perhaps, but I see it as part of paredit/parnifer's view of structural editing. Just like you can copy/paste code based on logical blocks (s-exprs) so you should be able to navigate based on "jump to definition" and "find usages"
yes, but I'm at the point where if I dump everything into one file, the # of entires I have overflows a single speedbar screen (that has full vertical height)
I guess the psychological problem is as follows: with code folding, previously, I could "fold all my code" -- then see all defs in a single screen; this is no longer possible when I'm dealing with files of length 5k loc
then it shows it in a vertical bar, and click,ing on it jumps me to the corresponding line in the file
I'll try this "large namespace" approach for a month or so, and if it doesn't work, I'll come back and complain later 🙂
no problem. And there's really no "right way" when it comes to editing. As long as you don't feel like you're fighting the language runtime
Can you think of some interesting/nice event systems for ClojureScript which are not focused on a specific react wrapper?
I found potok (https://github.com/funcool/potok) which is actually quite nice but unfortunately is a slight bit too opinionated
I’m more looking for something along the lines of re-frame’s dispatching stuff, zelkova, etc
I've used re-frame, but not xelkova; what exactly are ou looking for? fundamentally there's a bucnh of nodes, there's a topolotical sort, and other stuff gets updated with nodes gets updated
Something I can put events in that handles them in some async manner. Something like interceptors would be nice to implement my own stuff on top of that.
instead, IMO those events should be triggered by the navigation events ("user navigates to screen X")
the "things I want to do" include ajax requests, animations, setting timers. sending analytics events
@pesterhazy here's the example of how I approached navigation in Carry lib: https://github.com/metametadata/carry/blob/a04058c9ee3fef7e9f7a7971e381408bd22e10f1/examples/friend-list/src-public/friend_list/core.cljs#L48 In this sample project the url/token is synced with the search field. Demo online: https://metametadata.github.io/carry/examples/friend-list/
@martinklepsch I've read all the docs (and am a big fan) but I'm not using it right now
@pesterhazy What about Google Closure's PubSub? See https://google.github.io/closure-library/api/goog.pubsub.PubSub.html
the amount of hidden treasures in google.closure is unbelieveable, and too little documented within the cljs interop. Some todo for all of us.
holy moly, so true, @hlolli. the number of times i’ve been able to remove cljs libs (cljs-http, cljs-time in particular) just by accepting some interop
I've thought about that recently as well, would love some sort of curated list of the closure functions that are the most useful with cljs. For example,
goog.history seems to be used a lot while
goog.functions is basically useless from cljs
In my clojurescript code
(*.cljs files), how can i access functions or vars defined the clojure code
anything happen with non JVM package management? Remember there was some talk about it a few months ago
I’m torn between learning reagent vs om.next .. and honestly cannot google if om.next is released or still in alpha/beta
@ambrosebs One way is to start a Clojure REPL and then “piggyback” into a ClojureScript one.
@ambrosebs Have you figured out how to create a Clojure REPL? (If not, right click on your
project.clj and make one.)
Cool. One other thing @ambrosebs is to ensure that it has
cljs picked in the little pulldown.
Yeah, that pulldown doesn’t turn it into a ClojureScript REPL—it just informs Cursive how to behave with that REPL in the odd corner cases where it needs to be different.
So, if you are in a Clojure REPL then do the
(repl/repl (node/repl-env)) or whatever form would piggyback you into ClojureScript
Let @cfleming know if you use socket repl, maybe we can bug him enough to get some more socket repl+cursive features 🙂
Hey, I feel like this is a beginner question, but I'm trying to parse URLs out of random text while not losing the intermediate text, is there some function I'm missing to do it? Like I want to go from
"Check out to
["Check out " "
(re-seq) will give me just the links, and
(string/split) doesn't give me the links themselves if I match on eg
if you put your regex in a capture group i dont think the native js split function removes it
Well, I've wound up just splitting it on whitespace and then checking them word by word, which works fine but seems kind of inefficient
That's what I wanted to do, but you never get the matched split elements back from string/split
if you're in cljc then use the reader conditional to use the java string split vs js string split
Yeah, but I feel like this is just fundamental string processing, I shouldn't need to drop down to the host language to do it
I did. It works OK on the link case, not good on
"this is just text with no link" which I also need to handle
I got the best result along those lines with
#"(.*?)(https?://\S+)" matching prefix text plus link
I'm fine with the word-by-word solution for now, the perf hit isn't really noticable for my use case and the code is readable