This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-11
Channels
- # announcements (6)
- # architecture (14)
- # babashka (26)
- # beginners (22)
- # calva (11)
- # clj-kondo (2)
- # clj-on-windows (1)
- # cljsrn (10)
- # clojure (116)
- # clojure-europe (5)
- # clojure-uk (1)
- # clojurescript (5)
- # cursive (9)
- # datomic (21)
- # depstar (1)
- # events (1)
- # fulcro (2)
- # graalvm (17)
- # graalvm-mobile (28)
- # helix (3)
- # introduce-yourself (2)
- # jobs (2)
- # lsp (4)
- # meander (1)
- # off-topic (4)
- # pathom (5)
- # polylith (6)
- # practicalli (5)
- # reagent (67)
- # reitit (1)
- # releases (2)
- # shadow-cljs (24)
- # tools-deps (23)
Possible glitch? Pilot error? https://github.com/lilactown/helix-todo-mvc/issues/3 Looking at the code next...👀
The funny thing is that, were it not for the deviation from the reference implementation, the glitch might not have been noticeable.
OMG. Hooks. use-effect, use-reducer, use-layout-effect... if I could understand any of that I bet the dataflow works by updating local storage, relying on some dispatch off that to get the to-do to disappear based on the localStorage incarnation of the to-do.
The fix would be to make the maintenance of localStorage a pure side-effect of state changes to an in-memory to-do with reactive properties. Then the click to signify completion simply sets the to-do (reactive) property completed to true, and a watcher/observer sees the to-do has changed and re-writes the localstorage incarnation.
In Matrix, we use the term "observer" correctly in the sense of a bystander, and we can specify side-effects by type of property owner. In rxTrak, a to-do is a drug r/x that needs to be filled. rx-upsert
writes to localStorage:
(defmethod observe-by-type [:rxtrak.rx/rx] [slot me new-val old-val c]
(when-not (= old-val unbound)
(rx-upsert me)))
Translated, if any slot changes, upsert the whole to-do. (Observers are not called unless a property values changes.)