This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-26
Channels
- # beginners (74)
- # cider (3)
- # cljsrn (1)
- # clojure (182)
- # clojure-dev (4)
- # clojure-europe (1)
- # clojure-spec (5)
- # clojure-uk (58)
- # clojurescript (44)
- # core-async (5)
- # core-logic (10)
- # cursive (6)
- # datomic (13)
- # duct (1)
- # fulcro (2)
- # graalvm (4)
- # leiningen (1)
- # off-topic (7)
- # overtone (6)
- # random (3)
- # re-frame (17)
- # reitit (2)
- # shadow-cljs (6)
- # spacemacs (4)
- # sql (12)
- # tools-deps (3)
re-framers! merry xmas and all that! quick question from a Clojure n00b; I see that devcards currently don't play nice with re-frame. I have been researching the various libs, frameworks and tools in clojurescript for a while, and I think re-frame is exactly what I am after. However, devcards, or something similar would be a huge help. My project is essentially a softphone. And being able to build my UI without making/receiving phonecalls would be a huge productivity win, massive in fact! Is devcard support on the way? or an alternative available? or perhaps you can recommend another framework like re-frame that takes me beyond the reagent basics and will work well with devcards?
I haven’t used either myself so I can’t really give any solid recommendations, but you might be interested in https://github.com/nubank/workspaces
Ok, that's worth a look, I'll check out out, thanks for the tip @U4ZDX466T
I don’t think there’s any significant difference between workspaces and devcards regarding re-frame? Don’t the same problems apply to both?
Merry xmas everybody
Have you tried to put a conditional statement on a event?.
(rf/reg-event-fx
:customer/show
(fn [{:keys [db]} [_ id]]
{:db (->> id
(get (d/customers db))
(d/set-current db))
:dispatch [:customer/check-correspondence]}))
I would like to dispatch check-correspondence with a if condition. Is that possible?(rf/reg-event-fx
:customer/show
(fn [{:keys [db]} [_ id]]
(cond-> {:db (->> id
(get (d/customers db))
(d/set-current db))}
( false? (contains? (d/current db) :policy-correspondence)) (assoc :dispatch [:customer/default-correspondence]))))
Like this right?
Yeah. A few things though:
- {:keys [db]}
can be written as {db :db}
- a bit shorter, but only if you need just the DB and nothing else
- Don't use ->>
for getting by ID, use it to thread through collections instead. More details: https://stuartsierra.com/2018/07/06/threading-with-style
- Don't do false?
unless you need a strict check for false
. Just use not
.
What would you do instead of ->>
(rf/reg-event-fx
:customer/show
(fn [{:keys [db]} [_ id]]
(let [customer (get (d/customers db) id)]
(cond-> {:db (d/set-current db customer)}
(not ( customer :police-correspondence)) (assoc :dispatch-n [[:customer/item-changed :policy-correspondence "prod-manager"]
[:customer/item-changed :invoicing-correspondence "prod-manager"]])))))
My current code, it would better to call twice a event that does what i want instead of create a brand new. The condition is not working but i'm trying to figure out why.