Skip to content

Instantly share code, notes, and snippets.

@juristr
Created September 5, 2019 12:16
Show Gist options
  • Save juristr/365fda00df3f708c7ec09a9ba1eebd1d to your computer and use it in GitHub Desktop.
Save juristr/365fda00df3f708c7ec09a9ba1eebd1d to your computer and use it in GitHub Desktop.
rxjs toolbox
// https://twitter.com/niklas_wortmann/status/1167361268732370944
const observeOnMutation = (target, config): Observable<MutationRecord[]> => {
return new Observable((observer) => {
const mutation = new MutationObserver((mutaitons, instance) => {
observer.next(mutations);
});
mutation.observe(target, config);
const teardown = () => {
mutation.disconnect();
};
return teardown;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment