Skip to content
This repository was archived by the owner on Nov 3, 2024. It is now read-only.

Commit 30e4ecd

Browse files
authored
fix(utils): canExecuteFromNgForm add delay to cater for pristine changes (#63)
1 parent ace6802 commit 30e4ecd

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<!-- ## [vNext](https://github.com/sktch7/ngx.command/compare/2.0.0...3.0.0) (2020-x-x) -->
22

3+
## [2.1.0](https://github.com/sketch7/ngx.command/compare/2.0.0...2.1.0) (2022-07-12)
4+
5+
### Features
6+
7+
- **util:** `canExecuteFromNgForm` now have delay(0) which is fixing issue when observable `form.statusChanges` wasn't triggered after reset or make pristine form from the code.
8+
39
## [2.0.0](https://github.com/sketch7/ngx.command/compare/1.6.0...2.0.0) (2021-08-25)
410

511
### Features

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ssv/ngx.command",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"versionSuffix": "",
55
"description": "Command pattern implementation for angular. Command used to encapsulate information which is needed to perform an action.",
66
"keywords": [

src/command.util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AbstractControl, AbstractControlDirective } from "@angular/forms";
22
import { Observable, of } from "rxjs";
3-
import { map, distinctUntilChanged, startWith } from "rxjs/operators";
3+
import { map, distinctUntilChanged, startWith, delay } from "rxjs/operators";
44

55
import { CommandCreator, ICommand } from "./command.model";
66
import { Command } from "./command";
@@ -37,6 +37,7 @@ export function canExecuteFromNgForm(
3737

3838
return form.statusChanges
3939
? form.statusChanges.pipe(
40+
delay(0),
4041
startWith(form.valid),
4142
map(() => !!(!opts.validity || form.valid) && !!(!opts.dirty || form.dirty)),
4243
distinctUntilChanged(),

0 commit comments

Comments
 (0)