My next milestone will be to implement https://github.com/day8/re-frame/tree/master/examples/simple in Vrac.
I rewrote it already: https://github.com/green-coder/vrac-simple-sample/blob/master/src/simple/core.cljc
It is not working, but it shows how the event handler will look like.
Explanations here: https://twitter.com/VincentCantin/status/1383143229932015621
In vrac, where does the path come from?
> In Vrac, the "output" can be passed in the event next to the "input". Paths are unknown to the user. Trying to grok this. It seems like passing the "output" (I would call it a reference) is re-frame's work around for making updates less coupled to specific parts of the app db. Trying to understand vrac's approach.
The :event
and :logic
in Vrac are meant to be interpreted offline. They encode meaning instead of process.
As a result, if the human can understand what's going on while reading the event handler after reading the instruction manual, then a program can do the same and generate the code needed for the "process".
In Vrac, the path is conceptually passed alongside the value. It's as if the path was a metadata of the value.
so where does the path come from?
from the caller of the event triggering.
for the example [:time-color-change 34562]
, is the path in that event somewhere?
In this specific example, there is no path conveyed with 34562
However, (:time-color nil)
describe a data somewhere.
In Pathom's terms, that can be read as "the data reachable using :time-color
in the global context".
nil
is the global context
(:time-color my-timer)
would be the time-color in the context of a specific timer.
so the component dispatching the event would presumably pass '(:time-color my-timer)
as part of the event?
It could, yes.
In practice in Vrac, the user has very little need to call (v/dispatch event)
directly. Most of the time, the events would be dispatched from the Vrac component's "render function".
I do think the path dependence that's common in most frameworks is a challenge. membrane has some similar ideas (see https://blog.phronemophobic.com/reusable-ui-components.html). I still think there's lots of interesting ideas yet to be explored so I'm curious to see how vrac approaches the problem. I've been using the term "reference" to describe paths like '(:time-color my-timer)
.
> I do think the path dependence that's common in most frameworks is a challenge It's a handicap, mostly 🙂
Vrac plays a lot with the references, under the hood.
I am happy that you find the idea interesting.
When I say "reference", it doesn't necessarily mean just a "reference type" like an atom. Here's the definition I came up with: Reference: Data that uniquely identifies an entity within a data model.
Yes, that's what I understood.
> In practice in Vrac, the user has very little need to call `(v/dispatch event)` directly. Most of the time, the events would be dispatched from the Vrac component's "render function". What does that mean?
An example: https://github.com/green-coder/vrac-simple-sample/blob/master/src/simple/core.cljc#L75