I have a couple of options, but both seem a bit laggy, and I think there should be a better alternative. I just would like to be able to create forms, even dynamically create them (for example, add lines to a form from my application) and have the appropriate reagent / re-frame / appropriate access to the values ββof various inputs.
Not sure if either of these is a better alternative, as they both run functions after each :on-change ...
Option # 1 - update :on-change in the global atom
[:input {:value @new-job-form :on-change
Option # 2 - update some local state, which sends only to the global atom :on-blur
(defn text-input "adapted from: https://yogthos.net/posts/2016-09-25-ReagentComponents.html The big idea is this holds local state, and pushes it to the global state only when necessary" [{:keys [sub-path disp]}] (r/with-let [value (r/atom nil) focused? (r/atom false)] [:div [:input {:type :text :on-focus
The second option is a bit less lagged, but more laggy than just the original text input ...
EDIT:
Option No. 3 - For completeness, a slightly different flavor adapted from the repeated frame of TODOMVC
(defn text-input "adapted from re-frame TODOMVC: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/views.cljs note: this is one-way bound to the global atom, it doesn't subscribe to it" [{:keys [on-save on-stop props]}] (let [inner (r/atom "")] (fn [] [:input (merge props {:type "text" :value @inner :on-blur (on-save @inner) :on-change
source share