(key: string)
| 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) => { |
no test coverage detected
searching dependent graphs…