vrac

2021-09-24T14:20:55.002700Z

hey @smith.adriane 👋

2021-09-24T14:22:11.004Z

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.

2021-09-24T14:23:39.004900Z

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

2021-09-24T14:24:32.005900Z

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.

2021-09-24T14:26:36.006300Z

I made a proof of concept a while ago in this public repo: https://github.com/green-coder/vrac-simple-sample

phronmophobic 2021-09-24T17:43:51.008500Z

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)})))

phronmophobic 2021-09-24T17:50:31.008900Z

hopefully, it's a good sign!

phronmophobic 2021-09-24T17:55:22.011700Z

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?