Title
#thinking-together
Cole

Cole

12/07/2019, 4:41 PM
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.
4:47 PM
In the past, I approached this problem by establishing a
Model
type for every input that would hang onto a few interesting props—
{
  value: T, 
  isTouched: boolean,
  errors: Array<{id, display}>,
  warnings: Array<{id, display}>,
  notes: Array<{id, display}>
}
4:48 PM
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.
w

wtaysom

12/08/2019, 2:27 AM
Pay attention to representing invalid states. For instance, two fields who values must agree in some way.
g

Garth Goldwater

12/08/2019, 6:55 PM
i think microstates.js and maybe orbit.js have interesting ideas about this
Cole

Cole

12/08/2019, 7:06 PM
@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
g

Garth Goldwater

12/08/2019, 7:38 PM
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.
7:39 PM
oh! fulcro and pathom have some really really cool tools for forms (in clojure) but it’s a lot to learn at once
Cole

Cole

12/08/2019, 7:40 PM
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
g

Garth Goldwater

12/08/2019, 7:40 PM

https://youtu.be/IS3i3DTUnAI

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