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?
I thought the Replicant name was already used for another (or more) Clojure libraries
Library names don't have to be unique. That's why we have group id and artifact id.
Sure, sure... But people remember the names, not the other stuff. At least, I do.
There's always context. :)
> 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).
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.
Yeah was wondering, seems like completely separate solution for rendering like dumdom would need to be used to accomplish that simply.
Sounds like you want https://github.com/cjohansen/replicant Nothing to do with re-frame though
Was about to say that. Replicant sounds exactly like what you want
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
Video presentation on it: https://vimeo.com/861600197