Fork me on GitHub

@mhamzachippa When you get that data back from the API and you convert it from JSON to Clojure, you can do this to it

dev=> (update {:subscribed-events [1 2 3]} :subscribed-events set)
{:subscribed-events #{1 3 2}}

🙌 1

Alternatively, you could change your event code to

 (fn-traced [{:keys [db]} [_ event_id]]
   {:db (update-in db [:user :subscribed-events] (fn [events id] (conj (set events) id)) event_id)}))

; re-frame event to remove subscribed events from the database
 (fn-traced [{:keys [db]} [_ event_id]]
   {:db (update-in db [:user :subscribed-events] (fn [events id] (disj (set events) id)) event_id)}))
That forces the subscribed events to be a set before trying to add/remove elements from it.

🙌 1

(but fixing the data before you add it to the re-frame db map would be better!)


I’m trying to get started with and cannot figure out what I’m doing wrong. I’m basically trying to follow the instructions here:, but I can’t seem to get it to work. When I run my uberjar (built with clj -T:build uber) using java -jar obeya-0.1.1-standalone.jar, I get this error:

Error: Could not find or load main class obeya.main
Caused by: java.lang.ClassNotFoundException: obeya.main
This is my directory structure:
├── build.clj
├── deps.edn
├── src
│   └── obeya
│       └── main.clj
└── target

5 directories, 9 files
This is src/obeya/main.clj:
(ns obeya.main)

(defn -main [opts]
  (println "running"))
This is build.clj:
(ns build
  (:require [ :as b]))

(def app 'obeya)
(def version (format "0.1.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file (format "target/%s-%s-standalone.jar" (name app) version))

(defn clean [_]
  (b/delete {:path "target"}))

(defn uber [_]
  (clean nil)
  (b/copy-dir {:src-dirs ["src" "resources"]
               :target-dir class-dir})
  (b/compile-clj {:basis basis
                  :src-dirs ["src"]
                  :class-dir class-dir})
  (b/uber {:class-dir class-dir
           :uber-file uber-file
           :basis basis
           :main 'obeya.main}))
This is my deps.edn:
{:deps {}

 {:build {:deps {io.github.clojure/ {:git/tag "v0.7.5" :git/sha "34727f7"}}
          :ns-default build}}}
I’ve tried a bunch of things, but I have yet to get anything to work (either the build fails or I get the above error.)


Do you have (:gen-class) in the ns form in obeya/main.clj?


No, I do not.


Without that, you won't get a Java-callable main class.


Indeed, that fixed my issue. I’m going to write something in #improve-getting-started about how I got stuck.


If you create an app project via clj-new or deps-new, (:gen-class) should be present -- just like it is with lein new app myapp or similar.


I didn’t know those things existed. I haven’t found mention of them in the documentation, otherwise I would have started with one of those.


Community projects are rarely mentioned in the official docs.

Muhammad Hamza Chippa10:01:23

@seancorfield I changed it into maps now working like a charm. Thank you so much sir


Question about removing unneeded dependencies— I’m in the early stages of building an app/prototype and decided to use a different DB library. (No data committed yet; just changed my mind.) I already have the old one in deps.edn. Do I need to do anything else besides remove that line and add the new one? I assume because the app hasn’t been .jarred yet, the old library won’t do any more harm than just taking up a few extra MB on my local hard drive. Is that correct?


I'm currently working through this (excellent), and in, the author uses the following code to update an app-state atom with new data returned from an API:

(swap! app-state update-in [:temperatures :today :value] (constantly today))
(swap! app-state update-in [:temperatures :tomorrow :value] (constantly tomorrow))
and I was wondering what the difference was between using update-in with (constantly <value>) and just using assoc-in with <value>. I.e can I just do this instead:
(swap! app-state assoc-in [:temperatures :today :value] today)
This assoc-in version seemed to work when I tested it, but is there some reason why using update-in is preferred?


in this case they are equivalent, and assoc-in makes more sense


update* is for transforming values through a function


ok great, thank you!


Hi, there, I was using lein deps in the past, to know the conflicting artificats I have in my dependency tree. Now, I'm using deps.edn, but I don't know how to do the same? and don't find any reference on the web

❤️ 1

oh yes, It's a so tiny paragraph that I missed it. But as usual a simple and elegant solution, thx !

gratitude-danke 1

Hey, I'm trying to run clj in a docker container. So my image is FROM clojure CMD ["clj"] but when I run the image I get rlwrap: error: My terminal reports width=0 (is it emacs?)  I can't handle this, sorry!``


run clojure if you have no terminal, clj if you do (`docker -it` )


clj == clojure + rlwrap

👍 1

Thanks, didn't know that.