npm ngrx-forms 5.1.0

latest releases: 8.0.0, 7.0.0, 6.3.6...
4 years ago

Features

  • add functions onNgrxForms and wrapReducerWithFormStateUpdate to allow better integration with createReducer from ngrx 8 (ac95be2), closes #147

    They can be used as follows:

    import { createReducer } from '@ngrx/store';
    import { onNgrxForms, updateGroup, validate, wrapReducerWithFormStateUpdate } from 'ngrx-forms';
    import { required } from 'ngrx-forms/validation';
    
    export interface LoginFormValue {
      username: string;
      password: string;
      stayLoggedIn: boolean;
    }
    
    export const initialLoginFormValue: LoginFormValue = {
      username: '',
      password: '',
      stayLoggedIn: false,
    };
    
    export const validateLoginForm = updateGroup<LoginFormValue>({
      username: validate(required),
      password: validate(required),
    });
    
    const rawReducer = createReducer(
      {
        loginForm: createFormGroupState('loginForm', initialLoginFormValue),
        // your other properties...
      },
      onNgrxForms(),
      // your other reducers...
    );
    
    // wrapReducerWithFormStateUpdate calls the update function
    // after the given reducer; you can wrap this reducer again
    // if you have multiple forms in your state
    export const reducer = wrapReducerWithFormStateUpdate(
      rawReducer,
      // point to the form state to update
      s => s.loginForm,
      // this function is always called after the reducer
      validateLoginForm,
    );
  • add update functions for async validations (8985e99)

  • export constant ALL_NGRX_FORMS_ACTION_TYPES that is an array of all action types ngrx-forms provides (09aad36)

Bugfixes

  • allow setting async errors if the validation is not pending (3f5c6d0)
  • allow clearing async errors on groups and arrays if the validation is not pending (ff13472)

Don't miss a new ngrx-forms release

NewReleases is sending notifications on new releases.