MCPcopy
hub / github.com/final-form/final-form / getMutatorApi

Function getMutatorApi

src/FinalForm.ts:279–307  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

277
278 // bind state to mutators
279 const getMutatorApi = (key: string) => (...args: any[]) => {
280 // istanbul ignore next
281 if (mutators) {
282 // ^^ causes branch coverage warning, but needed to appease the Flow gods
283 const mutatableState: MutableState<FormValues, InitialFormValues> = {
284 formState: state.formState,
285 fields: state.fields,
286 fieldSubscribers: state.fieldSubscribers,
287 lastFormState: state.lastFormState,
288 };
289 const returnValue = mutators[key](args, mutatableState, {
290 changeValue,
291 getIn,
292 renameField,
293 resetFieldState: api.resetFieldState as (name: string) => void,
294 setIn,
295 shallowEqual,
296 });
297 state.formState = mutatableState.formState;
298 state.fields = mutatableState.fields;
299 state.fieldSubscribers = mutatableState.fieldSubscribers;
300 state.lastFormState = mutatableState.lastFormState;
301 runValidation(undefined, () => {
302 notifyFieldListeners(undefined);
303 notifyFormListeners();
304 });
305 return returnValue;
306 }
307 };
308
309 const mutatorsApi = mutators
310 ? Object.keys(mutators).reduce((result, key) => {

Callers 1

createFormFunction · 0.85

Calls 3

runValidationFunction · 0.85
notifyFieldListenersFunction · 0.85
notifyFormListenersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…