Fork me on GitHub
JP Silva02:01:10

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

JP Silva13:01:23

thanks @UFBL6R4P3! will look into those.

JP Silva13:01:21

@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.

JP Silva13:01:50

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

Carl Waerner19:01:29

@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! 🙂

JP Silva02:01:28

re-frame would be a plus but not required at the moment

Eric Ihli12:01:54

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?

Eric Ihli17:01:26

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.

👍 4

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"
      `(db/defquery ~(symbol  token-name) (str "MATCH (x:" ~token-name ") RETURN count(*)") ))


where db/defquery is a macro given to me by the authors of neo4j-clj


This will work now:

(defcountquery "User")
    (with-open [session (db/get-session local-db)]
      (User session))


But this will not:


(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

Carl Waerner19:01:02

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

👍 12

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


when you have something done you can share your code at #code-reviews

❤️ 4
Pavel Klavík23:01:02

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:

😍 4

is there a reduce-right of some form in clojure.core?


to be honest it never comes up


you can reduce over a vector backwards with (reduce f init (rseq [1 2 3 4 5]))


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


rseq might do the job, thanks 👍


a seq I can use with assoc-in ?


well it doesnt need to be a seq




can you show some example data?


it sounds like a vector plus rseq does what you want from reduce-right (cheap access to the most recent value)


         [["blahblah 1" {"my-key" 0}] ["blahblah 0" {"my-other-key" 101}]]
         [0 1 "my-key"]
=> [["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 ^


but I'd like to effectively push to the start of the vec


then you can reduce ordinarily


which I understand is not possible


I'll be performing assoc-in 99% of the time, and reduce the other 1%


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


assoc-in with positional things is uncommon too


you may want to consider @noisesmith’s suggestion to rework the representation


I'd like to try and be idiomatic with Clojure standards, so I'll try reworking it


thanks, both


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.


better be safe and make it both 🙂

🙃 4