This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-24
Channels
- # announcements (30)
- # asami (9)
- # babashka (37)
- # beginners (120)
- # calva (26)
- # cider (3)
- # clara (9)
- # clj-commons (7)
- # clj-kondo (17)
- # cljsrn (2)
- # clojure (32)
- # clojure-europe (56)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (4)
- # clojurescript (34)
- # conjure (1)
- # copenhagen-clojurians (8)
- # core-async (21)
- # cursive (2)
- # datahike (2)
- # datascript (5)
- # events (4)
- # fulcro (32)
- # graalvm (10)
- # heroku (3)
- # introduce-yourself (1)
- # jobs (2)
- # lsp (3)
- # luminus (1)
- # malli (8)
- # meander (15)
- # minecraft (1)
- # nrepl (2)
- # off-topic (57)
- # pathom (2)
- # polylith (35)
- # reagent (6)
- # reitit (8)
- # releases (1)
- # rewrite-clj (7)
- # shadow-cljs (21)
- # timbre (4)
- # tools-build (1)
- # tools-deps (33)
- # vrac (8)
hey @smith.adriane 👋
The effects work in a very weird way, where the data is passed to the effect handlers kind of "by reference". Concretely, it's the path in the DB which is passed, along with the values.
The effect then returns an hashmap of associations "data reference -> new-value"
This allows to describe a change while keeping track of what has changed very clear to the framework. There is no need to diff the DB to find what has changed before/after the effect handler.
I made a proof of concept a while ago in this public repo: https://github.com/green-coder/vrac-simple-sample
That's very similar to how membrane works too. The main difference being that references are distinguished by their values by having a $
as a prefix.
(defui todo-item [{:keys [todo]}]
(horizontal-layout
(on :mouse-down
(fn [[mx my]]
[[:delete $todo]])
(delete-X-button))
(basic/checkbox {:checked? (:complete? todo)})
(basic/textarea {:text (:description todo)})))
hopefully, it's a good sign!
1. what kind of db are you using? > it's the path in the DB which is passed 2. Do you have an example of what the path looks like? The path looks like the following in membrane:
[(keypath :a)
(keypath :b)
(keypath :c)
(keypath :d)]
example:
(def nested-data {:a {:b {:c {:d 1}}}})
(defui nested-view [{:keys [a]}]
(let [b (:b a)
c (:c b)
d (:d c)]
(ui/button "More!"
(fn []
[[:inc-counter $d]]))))
(ui/mouse-down (nested-view nested-data)
[0 0])
;; ([:inc-counter [(keypath :a)
;; (keypath :b)
;; (keypath :c)
;; (keypath :d)]])
This works well for nested data, but it doesn't quite feel right for data models with actual entities. Does vrac support a schema for the data model?