Skip to content

Instantly share code, notes, and snippets.

@MarsiBarsi
Last active November 3, 2022 00:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save MarsiBarsi/52a2c10d955bbf7ce2475681c5b12c73 to your computer and use it in GitHub Desktop.
Save MarsiBarsi/52a2c10d955bbf7ce2475681c5b12c73 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