Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 0369155

Browse files
committed
Use lettables in TOC
1 parent 57a3d76 commit 0369155

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: src/app/shared/table-of-contents/table-of-contents.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {DOCUMENT} from '@angular/platform-browser';
33
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
44
import {ScrollDispatcher, CdkScrollable} from '@angular/cdk/scrolling';
55
import {Subject} from 'rxjs/Subject';
6-
import 'rxjs/add/operator/filter';
7-
import 'rxjs/add/operator/takeUntil';
6+
import {filter} from 'rxjs/operators/filter';
7+
import {takeUntil} from 'rxjs/operators/takeUntil';
88

99
interface Link {
1010
/* id of the section*/
@@ -44,9 +44,10 @@ export class TableOfContents implements OnDestroy, OnInit {
4444
@Inject(DOCUMENT) private _document: Document) {
4545

4646
// Create new links and save root url at the end of navigation
47-
this._router.events
48-
.filter(event => event instanceof NavigationEnd)
49-
.takeUntil(this._destroyed)
47+
this._router.events.pipe(
48+
filter(event => event instanceof NavigationEnd),
49+
takeUntil(this._destroyed),
50+
)
5051
.subscribe(event => {
5152
const rootUrl = _router.url.split('#')[0];
5253
if (rootUrl !== this._rootUrl) {
@@ -57,7 +58,7 @@ export class TableOfContents implements OnDestroy, OnInit {
5758

5859
// Scroll to section when the fragment changes
5960
this._route.fragment
60-
.takeUntil(this._destroyed)
61+
.pipe(takeUntil(this._destroyed))
6162
.subscribe(fragment => {
6263
this._urlFragment = fragment;
6364
this.scrollFragmentIntoView();
@@ -67,7 +68,7 @@ export class TableOfContents implements OnDestroy, OnInit {
6768
ngOnInit() {
6869
// Update active link after scroll events
6970
this._scrollDispatcher.scrolled()
70-
.takeUntil(this._destroyed)
71+
.pipe(takeUntil(this._destroyed))
7172
.subscribe(scrollable =>
7273
this._ngZone.run(() => {
7374
this.updateScrollContainer(scrollable);

0 commit comments

Comments
 (0)