@ngneat/reactive-forms
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -340,2 +340,13 @@ (function (global, factory) { | ||
} | ||
function isObjectEmpty(obj) { | ||
return Object.keys(obj).length === 0 && obj.constructor === Object; | ||
} | ||
/** | ||
* @return {boolean} True if arrays are identical. | ||
*/ | ||
function compareArraysContent(left, right) { | ||
left = Array.isArray(left) ? left : []; | ||
right = Array.isArray(right) ? right : []; | ||
return left.length === right.length && left.every(function (value) { return right.includes(value); }); | ||
} | ||
@@ -342,0 +353,0 @@ function getControlValue(control) { |
@@ -34,2 +34,13 @@ import { from, isObservable, of } from 'rxjs'; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL25ldGFuZWxiYXNhbC93d3cvcmVhY3RpdmUtZm9ybXMvcHJvamVjdHMvbmduZWF0L3JlYWN0aXZlLWZvcm1zL3NyYy8iLCJzb3VyY2VzIjpbImxpYi91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFFLFlBQVksRUFBYyxFQUFFLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFMUQsTUFBTSxVQUFVLFdBQVcsQ0FBSSxLQUFjO0lBQzNDLE9BQU8sS0FBSyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2hELENBQUM7QUFFRCxNQUFNLFVBQVUsVUFBVSxDQUFDLENBQU07SUFDL0IsT0FBTyxPQUFPLENBQUMsS0FBSyxVQUFVLENBQUM7QUFDakMsQ0FBQztBQUVELE1BQU0sVUFBVSxLQUFLLENBQUMsQ0FBTTtJQUMxQixPQUFPLENBQUMsS0FBSyxJQUFJLElBQUksQ0FBQyxLQUFLLFNBQVMs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AgLi4udG9BZGRcbiAgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHJlbW92ZUVycm9yPEU+KGVycm9yczogRSwga2V5OiBrZXlvZiBFKSB7XG4gIGlmICghZXJyb3JzKSB7XG4gICAgcmV0dXJuIG51bGw7XG4gIH1cbiAgY29uc3QgdXBkYXRlZEVycm9ycyA9IHtcbiAgICAuLi5lcnJvcnNcbiAgfTtcbiAgZGVsZXRlIHVwZGF0ZWRFcnJvcnNba2V5XTtcbiAgcmV0dXJuIE9iamVjdC5rZXlzKHVwZGF0ZWRFcnJvcnMpLmxlbmd0aCA+IDAgPyB1cGRhdGVkRXJyb3JzIDogbnVsbDtcbn1cbiJdfQ== | ||
export function isObjectEmpty(obj) { | ||
return Object.keys(obj).length === 0 && obj.constructor === Object; | ||
} | ||
/** | ||
* @return {boolean} True if arrays are identical. | ||
*/ | ||
export function compareArraysContent(left, right) { | ||
left = Array.isArray(left) ? left : []; | ||
right = Array.isArray(right) ? right : []; | ||
return left.length === right.length && left.every(value => right.includes(value)); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiL1VzZXJzL25ldGFuZWxiYXNhbC93d3cvcmVhY3RpdmUtZm9ybXMvcHJvamVjdHMvbmduZWF0L3JlYWN0aXZlLWZvcm1zL3NyYy8iLCJzb3VyY2VzIjpbImxpYi91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsSUFBSSxFQUFFLFlBQVksRUFBYyxFQUFFLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFMUQsTUFBTSxVQUFVLFdBQVcsQ0FBSSxLQUFjO0lBQzNDLE9BQU8sS0FBSyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxD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sO1xuICB9XG4gIGNvbnN0IHVwZGF0ZWRFcnJvcnMgPSB7XG4gICAgLi4uZXJyb3JzXG4gIH07XG4gIGRlbGV0ZSB1cGRhdGVkRXJyb3JzW2tleV07XG4gIHJldHVybiBPYmplY3Qua2V5cyh1cGRhdGVkRXJyb3JzKS5sZW5ndGggPiAwID8gdXBkYXRlZEVycm9ycyA6IG51bGw7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBpc09iamVjdEVtcHR5KG9iaikge1xuICByZXR1cm4gT2JqZWN0LmtleXMob2JqKS5sZW5ndGggPT09IDAgJiYgb2JqLmNvbnN0cnVjdG9yID09PSBPYmplY3Q7XG59XG5cbi8qKlxuICogQHJldHVybiB7Ym9vbGVhbn0gVHJ1ZSBpZiBhcnJheXMgYXJlIGlkZW50aWNhbC5cbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIGNvbXBhcmVBcnJheXNDb250ZW50PFQgZXh0ZW5kcyBbXT4obGVmdDogVCwgcmlnaHQ6IFQpOiBib29sZWFuIHtcbiAgbGVmdCA9IEFycmF5LmlzQXJyYXkobGVmdCkgPyBsZWZ0IDogKFtdIGFzIFQpO1xuICByaWdodCA9IEFycmF5LmlzQXJyYXkocmlnaHQpID8gcmlnaHQgOiAoW10gYXMgVCk7XG4gIHJldHVybiBsZWZ0Lmxlbmd0aCA9PT0gcmlnaHQubGVuZ3RoICYmIGxlZnQuZXZlcnkodmFsdWUgPT4gcmlnaHQuaW5jbHVkZXModmFsdWUpKTtcbn1cbiJdfQ== |
@@ -38,2 +38,13 @@ import { FormArray as FormArray$1, FormControl as FormControl$1, FormGroup as FormGroup$1, FormBuilder as FormBuilder$1 } from '@angular/forms'; | ||
} | ||
function isObjectEmpty(obj) { | ||
return Object.keys(obj).length === 0 && obj.constructor === Object; | ||
} | ||
/** | ||
* @return {boolean} True if arrays are identical. | ||
*/ | ||
function compareArraysContent(left, right) { | ||
left = Array.isArray(left) ? left : []; | ||
right = Array.isArray(right) ? right : []; | ||
return left.length === right.length && left.every(value => right.includes(value)); | ||
} | ||
@@ -40,0 +51,0 @@ function getControlValue(control) { |
@@ -9,1 +9,6 @@ import { Observable } from 'rxjs'; | ||
export declare function removeError<E>(errors: E, key: keyof E): E; | ||
export declare function isObjectEmpty(obj: any): boolean; | ||
/** | ||
* @return {boolean} True if arrays are identical. | ||
*/ | ||
export declare function compareArraysContent<T extends []>(left: T, right: T): boolean; |
{ | ||
"name": "@ngneat/reactive-forms", | ||
"description": "(Angular Reactive) Forms with Benefits", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"schematics": "./schematics/collection.json", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -26,2 +26,4 @@ <p align="center"> | ||
✅ Offers (almost) seamless `FormControl`, `FormGroup`, `FormArray` Replacement<br> | ||
@@ -45,2 +47,3 @@ ✅ Allows Typed Forms! <br> | ||
- [Control Errors](#control-errors) | ||
- [Control Operators](#control-operators) | ||
- [ControlValueAccessor](#controlvalueaccessor) | ||
@@ -84,3 +87,3 @@ - [Form Builder](#form-builder) | ||
```ts | ||
import { FormGroup } from '@ngneat/reactive-forms'; | ||
import { FormGroup, FormControl } from '@ngneat/reactive-forms'; | ||
@@ -114,3 +117,3 @@ interface Profile { | ||
```ts | ||
import { FormGroup } from '@ngneat/reactive-forms'; | ||
import { FormGroup, FormControl } from '@ngneat/reactive-forms'; | ||
@@ -476,3 +479,24 @@ interface ProfileControls { | ||
``` | ||
## Control Operators | ||
Each `valueChanges` or `values$` takes an operator `diff()`, which emits only changed parts of form: | ||
```ts | ||
import { FormGroup, FormControl } from '@ngneat/reactive-forms'; | ||
const control = new FormGroup<string>({ | ||
name: new FormControl(''), | ||
phone: new FormGroup({ | ||
num: new FormControl(), | ||
prefix: new FormControl() | ||
}), | ||
skills: new FormArray([]) | ||
}); | ||
control.value$ | ||
.pipe(diff()) | ||
.subscribe(value => { | ||
// value is emitted only if it has been changed, and only the changed parts. | ||
}); | ||
``` | ||
## ControlValueAccessor | ||
@@ -479,0 +503,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
535720
3668
684