re-frame

Mateusz Mazurczak 2024-10-28T15:07:32.043859Z

I want my UI components to be pure data and for that I would need to use some global handling of on-click/change... events. So I would like something like this for UI (I'm using hiccup): [:button {:on-click [[:save-number] [:second-action]]} ^ So that my on-click in UI component is written as data, without passing the function to it. And I would like to have some global handler that will evaluate the re-frame dispatch when this on-click is triggered (something like event bus pattern) I was thinking about some global event-listeners, but there are multiple events to listen-to with edge-cases to cover and I'm not entirely sure how it will affect performance. But it seems to me like natural conclusion in clojure data oriented thinking, so Is there some library that works well with re-frame/reagent for this purpose?

reefersleep 2024-10-31T08:48:56.773309Z

I thought the Replicant name was already used for another (or more) Clojure libraries

p-himik 2024-10-31T08:55:58.783649Z

Library names don't have to be unique. That's why we have group id and artifact id.

reefersleep 2024-10-31T09:01:55.114349Z

Sure, sure... But people remember the names, not the other stuff. At least, I do.

p-himik 2024-10-31T09:21:13.117319Z

There's always context. :)

p-himik 2024-10-28T15:19:40.513939Z

> pure data But it doesn't mean that the components will be pure functions, right? Just confirming. For what you want to work you'd have to either alter Reagent or create some kind of a layer between your views and Reagent in order to turn stuff like {:on-click [:x]} into {:on-click the-fn-associated-with-x}. And it would work only for the elements and the keys that you specify - so you'd have to manually tell it that :on-click on :button must be processed (or maybe all :on-* on all elements, but that's risky if you use thirdparty components).

p-himik 2024-10-28T15:20:35.627139Z

All in all, I would suggest reconsidering. :) The idea has been around for quite some time, and in some cases it just isn't practical. Pretty sure that Reagent is one such case.

👍 1
Mateusz Mazurczak 2024-10-28T16:22:34.600159Z

Yeah was wondering, seems like completely separate solution for rendering like dumdom would need to be used to accomplish that simply.

hkjels 2024-10-28T16:34:35.747099Z

Sounds like you want https://github.com/cjohansen/replicant Nothing to do with re-frame though

john 2024-10-28T19:32:03.493509Z

Was about to say that. Replicant sounds exactly like what you want

john 2024-10-28T19:34:02.062669Z

I generally agree with @p-himik that this idea is questionable (where I've seen it in the wild) but I'm super impressed with the replicant impl and I intend on trying it out soon

john 2024-10-28T19:36:40.381429Z

Video presentation on it: https://vimeo.com/861600197