re-frame

olive 2025-04-09T16:12:57.449419Z

https://github.com/day8/re-frame/blob/master/docs/FAQs/laggy-input.md per this FAQ, one solution for laggy inputs is replacing on-change dispatches to dispatch-sync. per the docs, you shouldn't use dispatch-sync often. out of curiosity, what are the possible negative repercussions for using dispatch-sync in the on-change handler for all text inputs?

Omar 2025-04-12T11:34:43.086959Z

true, but if you're in the middle of editing a text input why would you want the value to suddenly change from underneath you?

Omar 2025-04-12T11:35:43.218099Z

if there was an exceptional case to be made i would personally probably just keep a ref to the text input and update it as needed instead of keeping the value tied to an atom that constantly updates as the user types. I have witnessed this lag/jank before of doing such a thing and never had to ship code like that before.

p-himik 2025-04-12T14:05:20.321689Z

> if you're in the middle of editing a text input That's irrelevant. With controlled components, the data drives the UI - exactly what re-frame is made for. Any chance to the app-db, regardless of where it comes from (be it user input or some other event) will update the input. With uncontrolled components, the UI is driving the state, and reversing the direction is quite a hassle. I mean, you do you, but personally I find using uncontrolled components to be drastically inferior.

Omar 2025-04-11T20:29:43.567819Z

why not use default-value instead of setting the value directly? I don't think I've ever set an input's :value to an atom

p-himik 2025-04-11T21:40:18.466859Z

Unless I'm missing something, that would mean that you're using uncontrolled inputs. Meaning, any changes to the data from outside of the inputs will not be registered by the inputs.

p-himik 2025-04-09T16:22:50.106589Z

None, if you keep its usage to user-controlled inputs.

olive 2025-04-09T16:27:20.089639Z

thanks! that's what i figured. presumably the overall consequence to trying to use it elsewhere is you're just continually bypassing the event queue which is Bad for the obvious reasons, right?

p-himik 2025-04-09T16:28:06.653159Z

That's my understanding of it, yes.

souenzzo 2025-04-15T19:15:56.351859Z

(See also: this problem has roots in reagent) https://github.com/reagent-project/reagent/blob/master/doc/ControlledInputs.md

p-himik 2025-04-15T19:19:58.151089Z

Is that really relevant? The re-frame lag is due to how it uses an internal queue - it would work the same exact way regardless of what Reagent uses.

souenzzo 2025-04-15T19:25:06.608129Z

even if you try to wrap the input and create a re-frame-friendly input component, using reagent directly, you will still have issues I took this path, trying to make a wrap to antd/Input, that works as a substitute to re-com/input-text. I ended up giving up 🙂 and styling re-com/input-text to look like an antd component.

p-himik 2025-04-15T19:29:59.479379Z

Well, yeah - but it will be different issues for different reasons. :) The only common bits are that it's about inputs and async stuff.