Skip to content

Instantly share code, notes, and snippets.

@mohamedaboelmagd
Forked from NetanelBasal/dirty-check-3.ts
Created March 13, 2022 07:41
Show Gist options
  • Save mohamedaboelmagd/652614a250cf0c9cee094124886f4545 to your computer and use it in GitHub Desktop.
Save mohamedaboelmagd/652614a250cf0c9cee094124886f4545 to your computer and use it in GitHub Desktop.
export function dirtyCheck<U>(source: Observable<U>) {
return function<T>(valueChanges: Observable<T>): Observable<boolean> {
const isDirty$ = combineLatest(
source,
valueChanges,
).pipe(
debounceTime(300),
map(([a, b]) => isEqual(a, b) === false),
startWith(false),
);
return isDirty$;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment