Hello, I'm working on an in-house forms library (m...
# thinking-together
Hello, I'm working on an in-house forms library (managing user input validation and submission, and establishing controlled inputs in HTML) does anyone have advice on favorite forms/input management patterns they've used? I'm most interested in separating view and state management as much as possible. I have a strong preference towards FRP.
In the past, I approached this problem by establishing a
type for every input that would hang onto a few interesting props—
Copy code
  value: T, 
  isTouched: boolean,
  errors: Array<{id, display}>,
  warnings: Array<{id, display}>,
  notes: Array<{id, display}>
This was a good approach imo due to the ability to aggregate models into larger models—for example only if all child models are touch is the super model touched.
Pay attention to representing invalid states. For instance, two fields who values must agree in some way.
i think microstates.js and maybe orbit.js have interesting ideas about this
@wtaysom thanks for the input. Validation is something I certainly see as something that can be applied to existing models in the context of forms. Then, we can apply the validation at any level in the form. @Garth Goldwater I experimented with microstates.js in the past and found it to be a little too generalized for my purposes. I had a hard time understanding the advantages of using microstates over JavaScript classes or groups of behavior subjects. Orbit looks very interesting and pretty ambitious as well. Thank you for sharing both of these. I'm sure there are parts of both that I can find inspirations from
i think the talks on microstates you can find on youtube do a lot better job of justifying its purpose than anything i’ve found on the web—essentially you get the benefits of immutability (rollback/history/undo, track who changes what) without a lot of the syntactical baggage.
oh! fulcro and pathom have some really really cool tools for forms (in clojure) but it’s a lot to learn at once
I'll look into fulcro and pathom. I have a soft spot for clojure and the macro system. I'm really happy you shared those options! Some of the best DSLs come out of the clojure community


is a pretty solid intro to the techniques if not the technology so much
👀 1