tracks last subscribed component key reference, each time component subscribes value be incremented, and such incremented value be used as key under which component will be subscribed
every form state has one root model. Root model is instance of FormModel nested models can reside as well on root model.
will use {@see lastSubscribedComponentKey} and put under it {@see ISubscribedEntry}
if any managed property was at least once updated, will become true. used for logic to specify identify if user started using the form.
state version be incremented on each update each time component renders, it's entry be updated with the version of this state. when it comes to decision if component should be updated, the version of update be compared to last rendered version, if they're same, or rendered version is bigger than state version it will be skipped. effectively this insures that component be updated exactly once for each version, preventing rerendering for e.g. nested components subscribed for same state.
used for ad hoc validations, whenever you provide in methods that accept InputUseOptions a validate, it will be added as default validation to a validator
returns serialized root model (including nested data) to object.
same as args for modelToObject
returns next id for subscriber. Internal id is incremented
calls isValid on validator {@see ModelValidator.isValid}.
optional if true, will as well call FormState.validate
creates props for inputs for root model. For details refer to makeInputPropsForModel
managed property
{@see InputUseOptions}
For usage in no edgecase, close to uncontrolled input scenarios that don't require performance tweaking. Usefull for cases when you work with standard html input. Return result shall be passed to an input as spreaded props.
model on which input will set value
property of model which will be updated
InputUseOptions different options where you can e.g. override validation behaviour
call returns following: return values are subset of return of useForInput, that can be passed directly to native inputs.
makes a changeEvent handler for updating model proeprty
will add named listener (named to avoid duplication/double firing), that will run whenever onValueChange, setValue will run
will unwrap events value and pass it to setValue
validates the property.
This is primary method to update the property on model from input. Other on change methods, call this anyway.
new value that be set
model on which value be set
property to update value on
exists for cases when you need to override it.
subscribes component to this state represented by extending instance, behind the scenes will call useState using someNumber as it's initial state. the updateState from called useState and supplied options, will be stored under generated key on subscribed entries (simple object on this instance), any time update is called, all entries be traversed and corresponding update func be called, leading to update. on unmount entry will be deleted by the key it was subscribed under.
as options may be passed:
updateDeps?: a function that returns an array of dependencies. Before the next update, same func be called, and it's contents compared against the result of previous call. If both are same, update will be ignored onUnsubscribed?: any cleanup function on component's unmount. options are optional
For usage in custom input wrappers, input/ui lib adaptations. This method calls use() behind the scenes and subscribes to formState changes. But it will not update on every change but only when stuff relevant to property is changed.
Call will also return a set of controls you can pass to input components like getValue(), onChange() on valueChange() and etc.
model to wired
property of model
onChange - handler for wrapped in ChangeEvent value, will get the value and pass to same onValueChange
will validate depending on options either all default validations, or passed in options.methods list of methods. this method calls ModelValidator.validate or ModelValidator.validateDefault, so see them for details.
Generated using TypeDoc
instances of this class will be responsible for managing logic and binding Models Validators and components together. For relevant usages refer to makeFormStateWithModel and makeFormModel