Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanepiper/fe0dec59abc53f9c34941a499b7d45d3 to your computer and use it in GitHub Desktop.
Save tanepiper/fe0dec59abc53f9c34941a499b7d45d3 to your computer and use it in GitHub Desktop.
replay-control-value-changes.ts
export class ReplayControlValueChanges<T> extends Observable<T> {
constructor(control: AbstractControl | AbstractControlDirective) {
super(subscriber => {
if (!control.valueChanges) {
throw new Error('Control does not have valueChanges');
}
control.valueChanges.pipe(startWith(control.value)).subscribe(subscriber);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment