Skip to content

Instantly share code, notes, and snippets.

@Komock
Created May 20, 2020 07:23
Show Gist options
  • Save Komock/3fd5ae44f633d96782a13d175fc9e1e5 to your computer and use it in GitHub Desktop.
Save Komock/3fd5ae44f633d96782a13d175fc9e1e5 to your computer and use it in GitHub Desktop.
RxJS Operator to pipe into zone
export function enterZone(zone: NgZone) {
return <T>(source: Observable<T>) =>
new Observable<T>(observer =>
source.subscribe({
next: (x) => zone.run(() => observer.next(x)),
error: (err) => observer.error(err),
complete: () => observer.complete()
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment