This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-13
Channels
- # aleph (1)
- # announcements (14)
- # aws (8)
- # babashka (3)
- # beginners (49)
- # cider (6)
- # clara (7)
- # clj-kondo (58)
- # cljs-dev (17)
- # clojure (65)
- # clojure-dev (45)
- # clojure-europe (5)
- # clojure-italy (4)
- # clojure-nl (25)
- # clojure-norway (3)
- # clojure-uk (68)
- # clojurescript (10)
- # cursive (5)
- # datomic (12)
- # emacs (24)
- # fulcro (149)
- # hoplon (56)
- # kaocha (2)
- # luminus (18)
- # malli (7)
- # off-topic (12)
- # other-languages (82)
- # reagent (16)
- # reitit (7)
- # shadow-cljs (44)
- # spacemacs (4)
- # tools-deps (48)
- # xtdb (17)
hi folks, what's a good book/tutorial/course on Reagent? I was thinking about something in the lines of creating an app end-to-end.
I don't myself but just curious, is there any particular app you'd like to see made? I'd like to perhaps keep it in mind if I ever find the time to write one myself
thanks @UFBL6R4P3! will look into those.
@UBCSS6NGK I prefer tutorials where the goal is to build an app using an specific technology/framework. The more features of the framework are used, the better but the goal is to have an working app at the end. I've seen many tutorials where the authors focus on showing specific features of the framework but they fail on showing the flow/journey of creating an app.
some of the things I'd expect to see in a beginners tutorial are: 1. set up the environment 2. how to structure your code in terms of folders and files 3. if the tutorial is focusing on the frontend it would still be nice to show a little bit of the backend implementation (even if all endpoints have their responses hardcoded). 4. how to write tests 5. authentication/authorization
@USJQXB1PW I agree with you that many tutorials fail to show the entire process in building an app. I'm following this thread, hopefully someone will know! 🙂
What does ClojureScript do with namespaced keywords?
(clj->js {:foo/bar "baz"})
== #js {:bar "baz"}
#js {:foo/bar "baz"}
==
> Failed to read input: clojure.lang.ExceptionInfo: JavaScript literal keys must be strings or unqualified keywords {:type :reader-exception, :line 1, :column 21, :file "repl-input.cljs"}
I'm trying to do navigation with ReactNavigation and use keywords as route keys and I'm curious if routes like {:home/settings ...}
and {:user/settings ...}
will end up conflicting, or if there will be any gotchas, like how do I access those using JS interop rather than directly as a clojure map? It looks like the JS interop just drops the namespace part of the keyword. Wouldn't that create a clash?
Found the answer to this myself by reading the description of clj->js
and js->clj
. Can pass an optional function to specify how keywords should be converted to JavaScript. The default function is just name
.
I'm using macros in anger for the first time and I appear to be holding something wrong---
(defmacro defcountquery
"Counts for things that we index"
[token-name]
`(db/defquery ~(symbol token-name) (str "MATCH (x:" ~token-name ") RETURN count(*)") ))
This will work now:
(defcountquery "User")
(with-open [session (db/get-session local-db)]
(User session))
(let [entity "ValueMap"]
(defcountquery entity)
(with-open [session (db/get-session local-db)]
((symbol entity) session)))
Note: I don't entirely follow why the neo4j-clj library requires you to wrap that string query with their defquery
macro
Hello everyone! I am Carl from Sweden and completely new to Clojure(script). I really need HELP! I did web development with PHP many years ago but I kind of stopped around 2010. I've been itching to get back in the game but all the javascript libraries etc etc just makes me really overwhelmed. I then found Clojure and it feels a lot more approachable...I've read and watched tons about Clojure and I really feel that this what I want to learn. However I am struggling to find "a workflow" I really enjoyed the tutorial on figwheel (very clear, and more importantly it doesn't presume that I know stuff that I don't) and I'm up and running with that now. I've decided I want to build a "Contacts" web app as my first project. I know what needs to be done: I need to make an interface where I can input data (name, email, phone number, notes) -> store that data -> read it and display it in the browser. But I'm stuck. I don't even know how to inject html into my website (do I use hiccup dependency?) so my question would be: where do I go from here? Is there any tutorial that you guys know of that I could follow, any book I should read? Or could I just ask all the questions here in Slack? Also, if someone wants to be my mentor until I can stand on my own legs, it would be so appreciated and welcomed! ☺️
as someone who has worked on multiple end-to-end clojure/cljs webapps for all the domain specific stuff, I recommend this book https://pragprog.com/book/dswdcloj3/web-development-with-clojure-third-edition
it makes a bunch of "arbitrary" decisions about libs / techniques to use, and last I checked they are all reasonable defaults
it will likely be helpful to get more familiar with Java webapp conventions as you go, but don't dive deep on that, clojure avoids a lot of the Java complexity (Spring etc.) without losing features
I would start just with a front-end app (keeping everything in memory) and use reagent + re-frame, both have excellent documentation online. For compilation, I would use shadow-cljs since it is really simple to setup. You could even base everything from our sample client made for introducing people to Clojurescript: https://github.com/ReOrgpad/example-client
I ask because I want the best of both worlds - a seq I can use with assoc-in
, but reduce over the last conj
'd item first
it sounds like a vector plus rseq does what you want from reduce-right (cheap access to the most recent value)
(assoc-in
[["blahblah 1" {"my-key" 0}] ["blahblah 0" {"my-other-key" 101}]]
[0 1 "my-key"]
"some-value"))
=> [["C:\\temp\\db\\1" {"my-key" "some-value"}] ["C:\\temp\\db\\0" {"my-other-key" 101}]]
conj to a list goes to the front:
(update {:a '(1 2 3)} :a conj 0)
=>
{:a (0 1 2 3)}
Another way is ^
in that case, you could use a fully indexed representation (eg. hash-map with numbers as keys) and use sort-by key / map val in the reduce step
you may want to consider @noisesmith’s suggestion to rework the representation
you could also rewrite your reduce to be commutative so foldr and foldl would preduce the same results
Should that be associative instead of commutative? Not finished with my first coffee of the day yet, so I could be off there.