Skip to content

Commit d8c9793

Browse files
salemdarmgechev
authored andcommitted
Use RxJS pipeables instead of lettables (#2241)
* upgrade dependencies * fix rxjs/operators path * use rxjs pipeables * drop operators.ts * drop usages of operators.ts
1 parent b8903dc commit d8c9793

File tree

8 files changed

+12
-21
lines changed

8 files changed

+12
-21
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ $ npm run build.prod.rollup.aot
100100
Your project will be compiled ahead of time (AOT), and then the resulting bundle will be tree-shaken and minified. During the tree-shaking process Rollup statically analyses your code, and your dependencies, and includes the bare minimum in your bundle.
101101

102102
**Notes**
103-
- Beware of non-static/side-effectful imports. These cannot be properly optimized. For this reason, even though tree-shaking is taking place the developer still needs to be careful not to include non-static imports that are unnecessary, as those referenced imports will always end up in final bundle. Special attention should be given to RxJs, which makes heavy use of non-static/side-effectful imports: make sure you only add the operators you use, as any added operators will be included in your final production bundle.
103+
- Beware of non-static/side-effectful imports. These cannot be properly optimized. For this reason, even though tree-shaking is taking place the developer still needs to be careful not to include non-static imports that are unnecessary, as those referenced imports will always end up in final bundle. Special attention should be given to RxJs, which makes heavy use of non-static/side-effectful imports: make sure you only [pipeable operators](https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md).
104104
- UMD modules result in code that cannot be properly optimized. For best results, prefer ES6 modules whenever possible. This includes third-party dependencies: if one is published in both UMD and ES6 modules, go with the ES6 modules version.
105105
- During a production build, CommonJs modules will be automatically converted to ES6 modules. This means you can use them and/or require dependencies that use them without any issues.
106106

@@ -379,7 +379,6 @@ Forks of this project demonstrate how to extend and integrate with other librari
379379
│   │   │   ├── i18n.providers.ts
380380
│   │   │   ├── main-prod.ts
381381
│   │   │   ├── main.ts
382-
│   │   │   ├── operators.ts
383382
│   │   │   └── shared
384383
│   │   │   ├── config
385384
│   │   │   │   └── env.config.ts
@@ -439,7 +438,6 @@ Forks of this project demonstrate how to extend and integrate with other librari
439438
│   │   ├── karma.d.ts
440439
│   │   ├── merge-stream.d.ts
441440
│   │   ├── open.d.ts
442-
│   │   ├── operators.d.ts
443441
│   │   ├── slash.d.ts
444442
│   │   ├── systemjs-builder.d.ts
445443
│   │   └── tildify.d.ts

src/client/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component } from '@angular/core';
22
import { Config } from './shared/config/env.config';
3-
import './operators';
43

54
/**
65
* This class represents the main application component.

src/client/app/operators.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/client/app/shared/name-list/name-list.service.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Observable } from 'rxjs/Observable';
4-
// import 'rxjs/add/operator/do'; // for debugging
4+
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
5+
import { catchError } from 'rxjs/operators/catchError';
6+
// import { tap } from 'rxjs/operators/tap'; // for debugging
57

68
/**
79
* This class provides the NameList service with methods to read names and add names.
@@ -21,9 +23,10 @@ export class NameListService {
2123
* @return {string[]} The Observable for the HTTP request.
2224
*/
2325
get(): Observable<string[]> {
24-
return this.http.get('assets/data.json')
25-
// .do(data => console.log('server data:', data)) // debug
26-
.catch(this.handleError);
26+
return this.http.get<string[]>('assets/data.json')
27+
.pipe(
28+
// tap((data: string[]) => console.log('server data:', data)), // debug
29+
catchError(this.handleError));
2730
}
2831

2932
/**
@@ -35,7 +38,7 @@ export class NameListService {
3538
const errMsg = (error.message) ? error.message :
3639
error.status ? `${error.status} - ${error.statusText}` : 'Server error';
3740
console.error(errMsg); // log to console instead
38-
return Observable.throw(errMsg);
41+
return new ErrorObservable(errMsg);
3942
}
4043
}
4144

tools/config/seed.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ export class SeedConfig {
512512
'node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
513513
'@angular/router/testing':
514514
'node_modules/@angular/router/bundles/router-testing.umd.js',
515-
'rxjs/operators': 'node_modules/rxjs/operators.js',
515+
'rxjs/operators/*': 'node_modules/rxjs/operators/*',
516516

517517
'app/': `${this.APP_BASE}app/`,
518518
// For test config
@@ -560,7 +560,7 @@ export class SeedConfig {
560560
'@angular/common/http':
561561
'node_modules/@angular/common/bundles/common-http.umd.js',
562562
'tslib': 'node_modules/tslib/tslib.js',
563-
'rxjs/operators': 'node_modules/rxjs/operators.js',
563+
'rxjs/operators/*': 'node_modules/rxjs/*',
564564
'dist/tmp/node_modules/*': 'dist/tmp/node_modules/*',
565565
'node_modules/*': 'node_modules/*',
566566
'*': 'node_modules/*'

tools/manual_typings/seed/operators.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/tasks/seed/build.bundle.rxjs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export = (done: any) => {
1818
paths: {
1919
'n:*': 'node_modules/*',
2020
'rxjs/*': 'node_modules/rxjs/*.js',
21-
'rxjs/operators': 'node_modules/rxjs/operators.js'
21+
'rxjs/operators/*': 'node_modules/rxjs/*'
2222
},
2323
map: {
2424
'rxjs': 'n:rxjs',

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"tools/manual_typings/seed/karma.d.ts",
3737
"tools/manual_typings/seed/merge-stream.d.ts",
3838
"tools/manual_typings/seed/open.d.ts",
39-
"tools/manual_typings/seed/operators.d.ts",
4039
"tools/manual_typings/seed/slash.d.ts",
4140
"tools/manual_typings/seed/systemjs-builder.d.ts",
4241
"tools/manual_typings/seed/tildify.d.ts",

0 commit comments

Comments
 (0)