vrac

Template-based web library [WIP] - https://github.com/green-coder/vrac Zulip archive: https://clojurians.zulipchat.com/#narrow/stream/180378-slack-archive/topic/vrac Clojureverse archive: https://clojurians-log.clojureverse.org/vrac
2020-08-23T03:08:02.001300Z

Today I decided to change the way I work, I am going to write down more about the process of developing Vrac.

2020-08-23T03:16:17.007300Z

Many things have changed since the last time I touched Vrac in february. • Minimallist now replaces Clojure Spec to describe the template’s model. • Diffuse was taken out of Vrac’s source code and improved, hopefully to be useful in Vrac at some point.

2020-08-23T03:22:24.011200Z

My roadmap for the next couple of months will be: • to have a new model of the template using Minimallist, and rethink the grammar from scratch. • to experiment again with the data access and data computation inside the template • to better document the bounderies of each Vrac’s component, how it fits with existing web libraries. • to get a fully working todolist sample app.

2020-08-23T03:45:06.019500Z

Vrac targets a data flow similar to Re-frame (dispatched events in the template, events are transformed into effects in event handlers), but implemented differently. • Effects on the database will be described using Diffuse, • Vrac will use “components” as a way to group together template, event handlers (whose implementation can be delegated to external functions if needed) and subscriptions. • Those components are treated as source of information. They are input of functions which outputs systems which will be used for running the web app.

2020-08-23T03:47:05.021300Z

Another goal of Vrac is to lessen the need to decide in advance where different parts of the application should run, in a client-server context.

2020-08-23T13:04:28.022600Z

o/ @yogthos

yogthos 2020-08-23T13:04:41.023Z

👋

2020-08-23T13:07:09.024600Z

I am currently playing with an experiment, transforming a subset of Clojure (as data) used in the html template into a graph of data transformations.

2020-08-23T13:08:24.025Z

I will get back once I get things working.

2020-08-23T18:37:42.026700Z

My brainstorming, today:

; Let's imagine that this is the local db.
(def global {:a 2
             :b 3
             :c 10
             :d 7})

(def calc-comp []
  (let [a (:a global)
        b (:b global)
        c (:c global)
        d (:d global)]
    [:div (+
            (*
              (+
                a
                b)
              c)
            d)]))

;; Each node is created at a place where the function needs to read a value.
(def compute-nodes
  [; Direct data access
   {:id 'x1
    :inputs [[:data-path :a]]}
   {:id 'x2
    :inputs [[:data-path :b]]}
   {:id 'x3
    :inputs [[:data-path :c]]}
   {:id 'x4
    :inputs [[:data-path :d]]}

   ; Compute nodes
   {:id 'y1
    :inputs [[:node 'x1] [:node 'x2]]
    :fn +}
   {:id 'y2
    :inputs [[:node 'y1] [:node 'x3]]
    :fn *}
   {:id 'y3
    :inputs [[:node 'y2] [:node 'x4]]
    :fn +}
   ; not sure if it is the right thing to do, but we can include the html update
   ; in the transformation graph, for fun.
   {:id 'z1
    :inputs [[:html-path 0]]}
   ; the :div node will re-render its content when 'y3 has a new value
   {:id 'z2
    :inputs [[:node 'z1] [:node 'y3]]
    :fn update-html-content}])

; Scenario 1: value of c changes from 10 to 11
; - node 'x3 has changing input, recompute its output
; - node 'y2 has changing input, recompute its output
; - node 'y3 has changing input, recompute its output
; - node 'z2 has changing input, recompute its output
; Done, the html node has been updated.