This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
Hi everyone. I’ve got this component
(defn project-view
[defaults]
(let [form-state (r/atom defaults)]
(fn [project]
[:div.form-group]
;; and a bunch of stuff
)))
so I put all the defaults in that form-state
and then use that atom to update things in the form. once I click on submit
, I’m sending a post request to the server and it returns back an updated model. So what I want to do is to replace those defaults
with the updated model basically. So this is what I came up with and was wondering if there’s another way of doing it
(defn project-view
[defaults]
(let [original (r/atom defaults)
form-state (r/atom defaults)]
(fn [project]
(let [state @form-state
defaults @original]
(when (not= defaults project)
(reset! original project)
(reset! form-state project))
[:div.form-group]
;; and a bunch of stuff
))))