I have been trying to interpret this article but with newer RxJS the needed syntax has changed. There is something I don't get. My working AsyncValidator
's validate
method looks like this:
validate(control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> {
return Observable.create(resolve => {
const pathname = control.value;
if (!pathname || pathname.length < 1) { resolve(null); return; }
this.client.pathCheck(this.parentPath + '/' + pathname).subscribe(
resp => resolve.next(resp.inuse ? { pathInUse: true } : null),
err => resolve.next(null),
() => resolve.complete(null)
);
});
}
What I don't understand is how to fit in the timer
, pipe
, and switchMap
functions to replace the Observable.create
.
What I also don't understand is why the debounce
pipe isn't used for this.
Any help much appreciated.