humbleui

Niki 2023-12-08T20:56:06.920099Z

Trying to use Rich’s decision matrix to make, well, a decision. What a great method!

💯 13
1
➕ 1
Paul Hempel 2023-12-10T14:23:42.177039Z

Wouldn’t it be an option to include the lifecycle methods into the options map of a ui element?:

(defn timer []
  (let [state (atom 0)]
    [col {:on-mount #(,,,)
          :on-unmount #(,,,)}
      ,,,]))
It would be somewhat familiar to frontend (Hiccup, HTML), still uses Clojure style concepts, arrays will be an option for multiple hooks as well, captures local variables, has no special rules, and probably no runtime overhead (guessing from last variant). Also you could keep it simple and omit the opts map if you don’t need it or include it as the first argument if you extend an existing component. The other options look like a more complex rewrite, if someone later decides to add interaction to a static component.

Darrick Wiebe 2023-12-08T22:20:05.019329Z

Definitely. I've had a similar experience when I've tried this method on difficult decisions in the project I've been working on. It really helps clarify my thinking in a way that also makes it easy to explain how I made my decision to others.

➕ 1
lilactown 2023-12-09T01:36:58.941289Z

I too have used this to great effect since watching his talk 🙂

➕ 2
lilactown 2023-12-09T01:43:40.876989Z

in "combining multiple hooks" I would also consider:

(defn use-fetch ,,,)
(defn use-watch ,,,)

(defn use-foo
  [,,,]
  ;; I want to use two `use-fetch` and a `use-watch` in this. How?
  )  

Niki 2023-12-09T07:29:56.558099Z

Nested arrays I guess

Stig Brautaset 2023-12-11T11:24:42.073669Z

Can I (humbly) ask which of Rich's talks this technique is from?

Paul Hempel 2023-12-11T11:26:54.047919Z

@stig328 https://www.youtube.com/watch?v=c5QF2HjHLSE the latest one 😉

1
Niki 2023-12-11T12:51:48.252319Z

@paul.hempel I feel that would be wrong place to put them. Callbacks belong to component, not to the markup inside it