ngrx-forms
Advanced tools
Changelog
6.1.0
<a name="6.0.0"></a>
Changelog
6.0.0
This major release contains only a bugfix which is a breaking change.
do not treat empty strings or arrays as an error in minLength
validation function (#164), thanks @Sloff for reporting and fixing this bug
If you require these values to be treated as errors use minLength
together with required
(e.g. validate(required, minLength(2))
)
<a name="5.2.3"></a>
Changelog
5.2.0
add function onNgrxFormsAction
that allows specifying a reducer for ngrx-forms actions with createReducer
from ngrx 8 (5cdf9c6)
It can be used as follows:
import { createReducer } from '@ngrx/store';
import {
onNgrxForms,
onNgrxFormsAction,
SetValueAction,
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 reducer = createReducer(
{
loginForm: createFormGroupState('loginForm', initialLoginFormValue),
// your other properties...
},
onNgrxForms(),
// use this to call a reducer for a specific ngrx-forms action;
// note that this must be placed after onNgrxForms
onNgrxFormsAction(SetValueAction, (state, action) => {
if (action.controlId === 'loginForm.username') {
// react to username changing...
// action is of type SetValueAction
}
return state;
}),
// your other reducers...
);
<a name="5.1.0"></a>
Changelog
5.1.0
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)
<a name="5.0.3"></a>
Changelog
5.0.0
This is a compatibility release for Angular 8 and TypeScript 3.4.
>=8.0.0
>=3.4.0
FormState
and Unboxed
conditional type definitions to be simpler, which can improve build times and IDE performance (e9f504b), (24b25db)FormState
and Unboxed
types (255c648)<a name="5.0.0-beta.2"></a>