I am building a re-frame application and use re-com DOM elements, among others the
re-com/input-text element. The value in the text element is not pushed to the app-db until the input loses focus, which is the default behavior.
One really annoying thing when I have 10x and spec checking of the app-db turned on, meaning that it takes some time after the new value is dispatched until it is saved, is that the text in the input field reverts to its old value until it gets the new value back again from the subscription. That is, after leaving the input field, the old value is shown for a short time, and then the new value is shown again.
Basically, the code looks like this
(re-frame/reg-sub :test-sub (fn [db] (:test-sub db))) (re-frame/reg-event-db :test-event (fn [db [_ value]] (assoc db :test-sub value))) (defn main-panel  (let [test (re-frame/subscribe [:test-sub])] [re-com/v-box :height "100%" :children [[:span @test] [re-com/input-text :model test :on-change #(re-frame/dispatch [:test-event %])]]]))
Can I prevent this behavior somehow?
This is also noticeable, although the delay is much shorter, in the lightweight re-frame template app. I’ve made a quick demonstration of the phenomenon available at https://github.com/brjann/re-frame-test