import { Action } from './actions'; import { AbstractControlState, FormState } from './state'; import { ProjectFn } from './update-function/util'; export declare function formStateReducer(state: FormState | AbstractControlState | undefined, action: Action): FormState; /** * This function creates a reducer function that first applies an action to the state * and afterwards applies all given update functions one after another to the resulting * form state. However, the update functions are only applied if the form state changed * as result of applying the action. If you need the update functions to be applied * regardless of whether the state changed (e.g. because the update function closes * over variables that may change independently of the form state) you can simply apply * the update manually (e.g. `updateFunction(formStateReducer(state, action))`). * * The following (contrived) example uses this function to create a reducer that after * each action validates the child control `name` to be required and sets the child * control `email`'s value to be `''` if the name is invalid. * * ```typescript * interface FormValue { * name: string; * email: string; * } * * const updateFormState = updateGroup( * { * name: validate(required), * }, * { * email: (email, parentGroup) => * parentGroup.controls.name.isInvalid * ? setValue('', email) * : email, * }, * ); * * const reducer = createFormStateReducerWithUpdate(updateFormState); * ``` */ export declare function createFormStateReducerWithUpdate(updateFnOrUpdateFnArr: ProjectFn> | ProjectFn>[], ...updateFnArr: ProjectFn>[]): (state: FormState | undefined, action: Action) => FormState;