You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's currently no way of composing them. Such composition should:
Return the same data structure as the form itself enriched with extra context, so the form would have to be "lifted" in monadic terms.
On submitting the entire form, carry over results from earlier forms, effectively making the composition a monad. This allows us to compose submits generically, since we can have a subform that depends on results from previous subforms.
Those are the harder ones. The semantics of composing reset, validate, etc... are trivial. We just iterate through the composed forms and call those methods in order.
The text was updated successfully, but these errors were encountered:
Just summarizing our off-github conversation: I'm not sure I see the value in this because it's trivial to compose fields (just use object spread) and submit methods are just functions (so you can compose them as you would other functions). The net savings would likely be a few lines of code but would come at the cost of introducing new concepts and API surface for form composition (instead of just regular functional/object composition).
With that said, we definitely should at least create a canonical example of doing this, even if there's no official API (like how focusing a field has a demo, but no underlying actual API is needed in this library).
Say you've got a couple forms
form1
andform2
like the example in the readme:There's currently no way of composing them. Such composition should:
submit
s generically, since we can have a subform that depends on results from previous subforms.Those are the harder ones. The semantics of composing
reset
,validate
, etc... are trivial. We just iterate through the composed forms and call those methods in order.The text was updated successfully, but these errors were encountered: