Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35597f8

Browse files
committed
chain subscriptions
1 parent 71a81f6 commit 35597f8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/content.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,19 @@ const onDiffView = (commitSpec: CommitSpec, repo: Repo) => {
752752
root: HTMLElement,
753753
onJsFile: (jsFile: HTMLElement) => Unsubscribable
754754
): Subscribable<never> =>
755-
new Observable(_subscriber => {
756-
observeNewChildren(root).subscribe(el => {
757-
const elTeardown = new Subscription()
758-
if (el.classList.contains('js-file')) elTeardown.add(onJsFile(el))
759-
if (el.classList.contains('js-diff-progressive-container'))
760-
elTeardown.add(observeJsFilesUnder(el, onJsFile).subscribe())
761-
return elTeardown
762-
})
763-
})
755+
observeNewChildren(root).pipe(
756+
mergeMap(
757+
el =>
758+
new Observable(_subscriber => {
759+
const elTeardown = new Subscription()
760+
if (el.classList.contains('js-file')) elTeardown.add(onJsFile(el))
761+
if (el.classList.contains('js-diff-progressive-container'))
762+
elTeardown.add(observeJsFilesUnder(el, onJsFile).subscribe())
763+
return elTeardown
764+
})
765+
),
766+
ignoreElements()
767+
)
764768

765769
const path2Anchor = new Map<string, string>()
766770
const j2d = (range: RepoCommitPathRange) => {

0 commit comments

Comments
 (0)