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

Commit b029f91

Browse files
amcdnljelbourn
authored andcommitted
chore: switch to rxjs lettables (#344)
1 parent 9c78345 commit b029f91

File tree

9 files changed

+22
-27
lines changed

9 files changed

+22
-27
lines changed

src/app/material-docs-app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, ViewEncapsulation} from '@angular/core';
22
import {Router, NavigationEnd} from '@angular/router';
3-
import 'rxjs/add/operator/filter';
3+
import {filter} from 'rxjs/operators/filter';
44

55

66
@Component({
@@ -15,7 +15,7 @@ export class MaterialDocsApp {
1515
let previousRoute = router.routerState.snapshot.url;
1616

1717
router.events
18-
.filter(event => event instanceof NavigationEnd )
18+
.pipe(filter(event => event instanceof NavigationEnd))
1919
.subscribe((data: NavigationEnd) => {
2020
// We want to reset the scroll position on navigation except when navigating within
2121
// the documentation for a single component.

src/app/pages/component-category-list/component-category-list.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {DocumentationItems, SECTIONS} from '../../shared/documentation-items/doc
66
import {ComponentPageTitle} from '../page-title/page-title';
77
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
88
import {Observable} from 'rxjs/Observable';
9-
import 'rxjs/add/observable/combineLatest';
9+
import {combineLatest} from 'rxjs/observable/combineLatest';
1010
import {Subscription} from 'rxjs/Subscription';
1111

1212

@@ -25,7 +25,7 @@ export class ComponentCategoryList implements OnInit, OnDestroy {
2525

2626
ngOnInit() {
2727
// Combine params from all of the path into a single object.
28-
this.params = Observable.combineLatest(
28+
this.params = combineLatest(
2929
this._route.pathFromRoot.map(route => route.params),
3030
Object.assign);
3131

src/app/pages/component-list/component-list.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
99
import {CommonModule} from '@angular/common';
1010
import {MatCardModule} from '@angular/material';
1111
import {Observable} from 'rxjs/Observable';
12-
import 'rxjs/add/observable/combineLatest';
12+
import {combineLatest} from 'rxjs/observable/combineLatest';
1313

1414
@Component({
1515
selector: 'app-components',
@@ -24,8 +24,7 @@ export class ComponentList {
2424
private _componentPageTitle: ComponentPageTitle,
2525
private _route: ActivatedRoute,
2626
public router: Router) {
27-
Observable
28-
.combineLatest(_route.pathFromRoot.map(route => route.params), Object.assign)
27+
combineLatest(_route.pathFromRoot.map(route => route.params), Object.assign)
2928
.subscribe(p => {
3029
this.category = docItems.getCategoryById(p['id']);
3130
this.section = p['section'];

src/app/pages/component-page-header/component-page-header.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Component, EventEmitter, NgModule, Output} from '@angular/core';
2-
import 'rxjs/add/operator/first';
32
import {ComponentPageTitle} from '../page-title/page-title';
43
import {NavigationFocusModule} from '../../shared/navigation-focus/navigation-focus';
54
import {MatButtonModule, MatIconModule} from '@angular/material';

src/app/pages/component-sidenav/component-sidenav.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {CommonModule} from '@angular/common';
77
import {ComponentHeaderModule} from '../component-page-header/component-page-header';
88
import {FooterModule} from '../../shared/footer/footer';
99
import {Observable} from 'rxjs/Observable';
10+
import {combineLatest} from 'rxjs/observable/combineLatest';
1011

1112
const SMALL_WIDTH_BREAKPOINT = 720;
1213

@@ -39,7 +40,7 @@ export class ComponentSidenav implements OnInit {
3940
});
4041

4142
// Combine params from all of the path into a single object.
42-
this.params = Observable.combineLatest(
43+
this.params = combineLatest(
4344
this._route.pathFromRoot.map(route => route.params),
4445
Object.assign);
4546
}

src/app/pages/component-viewer/component-viewer.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import {CommonModule} from '@angular/common';
22
import {Component, ElementRef, NgModule, OnInit, ViewChild, ViewEncapsulation} from '@angular/core';
33
import {MatTabsModule} from '@angular/material';
44
import {ActivatedRoute, Params, Router, RouterModule} from '@angular/router';
5-
import 'rxjs/add/operator/map';
6-
import {Observable} from 'rxjs/Observable';
75
import {DocViewerModule} from '../../shared/doc-viewer/doc-viewer-module';
86
import {DocItem, DocumentationItems} from '../../shared/documentation-items/documentation-items';
97
import {TableOfContentsModule} from '../../shared/table-of-contents/table-of-contents.module';
108
import {ComponentPageTitle} from '../page-title/page-title';
11-
9+
import {combineLatest} from 'rxjs/observable/combineLatest';
10+
import {map} from 'rxjs/operators/map';
1211

1312
@Component({
1413
selector: 'app-component-viewer',
@@ -27,10 +26,9 @@ export class ComponentViewer {
2726
public docItems: DocumentationItems) {
2827
// Listen to changes on the current route for the doc id (e.g. button/checkbox) and the
2928
// parent route for the section (material/cdk).
30-
Observable.combineLatest(_route.params, _route.parent.params)
31-
.map((p: [Params, Params]) => ({id: p[0]['id'], section: p[1]['section']}))
32-
.map(p => docItems.getItemById(p.id, p.section))
33-
.subscribe(d => {
29+
combineLatest(_route.params, _route.parent.params).pipe(
30+
map((p: [Params, Params]) => ({id: p[0]['id'], section: p[1]['section']})),
31+
map(p => docItems.getItemById(p.id, p.section))).subscribe(d => {
3432
this.componentDocItem = d;
3533
if (this.componentDocItem) {
3634
this._componentPageTitle.title = `${this.componentDocItem.name}`;

src/app/shared/example-viewer/example-viewer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Component, Input} from '@angular/core';
22
import {MatSnackBar} from '@angular/material';
33
import {ComponentPortal} from '@angular/cdk/portal';
4-
import 'rxjs/add/operator/first';
54

65
import {EXAMPLE_COMPONENTS, LiveExample} from '@angular/material-examples';
76
import {CopierService} from '../copier/copier.service';

src/app/shared/stackblitz/stackblitz-writer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Injectable} from '@angular/core';
22
import {Http} from '@angular/http';
33
import {ExampleData} from '@angular/material-examples';
4-
import 'rxjs/add/operator/toPromise';
54
import {VERSION} from '@angular/material';
65

76
const STACKBLITZ_URL = 'https://run.stackblitz.com/api/angular/v1/';

src/app/shared/table-of-contents/table-of-contents.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {Component, ElementRef, Inject, Input, OnInit} from '@angular/core';
22
import {DOCUMENT} from '@angular/platform-browser';
33
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
4-
import 'rxjs/add/observable/fromEvent';
5-
import 'rxjs/add/operator/debounceTime';
6-
import 'rxjs/add/operator/takeUntil';
7-
import {Observable} from 'rxjs/Observable';
84
import {Subject} from 'rxjs/Subject';
5+
import {debounceTime} from 'rxjs/operators/debounceTime';
6+
import {takeUntil} from 'rxjs/operators/takeUntil';
7+
import {fromEvent} from 'rxjs/observable/fromEvent';
8+
99

1010
interface Link {
1111
/* id of the section*/
@@ -45,7 +45,7 @@ export class TableOfContents implements OnInit {
4545
private _element: ElementRef,
4646
@Inject(DOCUMENT) private _document: Document) {
4747

48-
this._router.events.takeUntil(this._destroyed).subscribe((event) => {
48+
this._router.events.pipe(takeUntil(this._destroyed)).subscribe((event) => {
4949
if (event instanceof NavigationEnd) {
5050
const rootUrl = _router.url.split('#')[0];
5151
if (rootUrl !== this._rootUrl) {
@@ -55,7 +55,7 @@ export class TableOfContents implements OnInit {
5555
}
5656
});
5757

58-
this._route.fragment.takeUntil(this._destroyed).subscribe(fragment => {
58+
this._route.fragment.pipe(takeUntil(this._destroyed)).subscribe(fragment => {
5959
this._urlFragment = fragment;
6060

6161
const target = document.getElementById(this._urlFragment);
@@ -72,9 +72,9 @@ export class TableOfContents implements OnInit {
7272
this._scrollContainer = this.container ?
7373
this._document.querySelectorAll(this.container)[0] : window;
7474

75-
Observable.fromEvent(this._scrollContainer, 'scroll')
76-
.takeUntil(this._destroyed)
77-
.debounceTime(10)
75+
fromEvent(this._scrollContainer, 'scroll').pipe(
76+
takeUntil(this._destroyed),
77+
debounceTime(10))
7878
.subscribe(() => this.onScroll());
7979
});
8080
}

0 commit comments

Comments
 (0)