Fork me on GitHub
Vincent Cantin14:09:11

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.

Vincent Cantin14:09:39

The effect then returns an hashmap of associations "data reference -> new-value"

Vincent Cantin14:09:32

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.

Vincent Cantin14:09:36

I made a proof of concept a while ago in this public repo:


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]}]
   (on :mouse-down
    (fn [[mx my]]
      [[:delete $todo]])
   (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)]
(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?