Fork me on GitHub
#clojurescript
<
2023-04-24
>
alandipert21:04:53

greetings clojurescriptians, just wanted to swing by and let you all know we're doing a virtual #hoplon meetup on Wednesday and we'd love to have you - https://clojurians.slack.com/archives/C08BDAPRA/p1681928909048129

alandipert21:04:44

in case you didn't know, http://hoplon.io/ is a library for doing SPAs without React involvement; API similar to Reagent though it's been dead/dormant/"done" for years, but interest is starting to pick back up again, and it could be a fun time to check it out if you're interested. thanks, hope to see you there!

❤️ 4
kennytilton23:04:50

Any Lisper can tell you, there is dead and then there is "dead". The transparency, the "T" in TRFP, truly sets Hoplon apart. Happy Renaissance! 🎂

simple_smile 2
shaunlebron18:04:52

@U0PUGPSFR where can I read about this “transparency” in hoplon?

kennytilton19:04:13

Hey @U061E2UBT. I should let the Hoplon crew answer, but I am referring to the absence of either explict subscribe or publish syntax, which we can see in their opening example:

(ns your-ns
  (:require [javelin.core :refer [cell] :refer-macros [cell=]]))

(defn start []
  (let [a (cell 0)              ;; input cell with initial value of 0.
        b (cell= (inc a))       ;; formula cell of a+1.
        c (cell= (+ 123 a b))]  ;; formula cell of a+b+123.
    (cell= (.log js/console c)) ;; anonymous formula cell for side effects.
    ;; c's initial value, 124, is printed.
    (swap! a inc)
    ;; a was incremented, and its new value propagated (consistently)
    ;; through b and c.  c's new value, 126, is printed to the console.
    ))
Note that the formula for c simplify reads a and b and becomes reactively connected. Note esp. that the above works if, say, b had been bound to 42. There is no need to code anything like (subscribe a). Likewise, the mutation (swap! a inc) suffices to trigger recalculation of b and c. No need for an explicit (publish a). One neat thing here is that, because both publish and subscribe happen automatically, our coding is more relaxed and reliable: if we use a cell, we are also subscribed to it. (I do not know if H/J has "back door" overrides -- my own package has a without-dependency macro, and un-reactive mutation or reading can be achieved by bypassing the package's API. 🙂

shaunlebron19:04:17

@U0PUGPSFR ah I see, thank you for the rundown 🙂 I looked at the internals of how reagent works, and what you described reminds me of it. Reagent figures out when components should be updated by just watching which atoms are dereferenced in the previous frame, if I remember correctly. Then any swaps on those atoms will trigger an update in the next animation frame. So thanks, I see now why Alan said Hoplon was similar. 👍

kennytilton20:04:23

But there is still exposed wiring with Reagent. A ratom is like a reactive clearinghouse, a first-class entity that exists only to support reactivity. In truly transparent systems, we just have application properties talking to each other, not some artifice thru which properties communicate. The a-b-c example was too focused on pedagogy to show this, but in real world examples we would see, say, a to-do item completed? property and its container style or class that considers the to-do's completed? value -- no ratom involved. That said, I agree that Reagent felt more familiar to me than re-frame's app-db with its explicit subscriptions and transactions.