Skip to content

Commit 0641f9e

Browse files
committed
feat: update to rxjs 5.5.0 and switch to lettable operators
Bumps the required RxJS version to 5.5.0 and gets rid of our RxChain in favor of using the lettable Rx operators. Refactors all the usages and updates the configs. Fixes #7275.
1 parent 3571f68 commit 0641f9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+287
-600
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ src/lib/core/datetime/** @mmalerba
4848

4949
# CDK
5050
src/cdk/coercion/** @jelbourn
51-
src/cdk/rxjs/** @jelbourn
5251
src/cdk/observers/** @jelbourn @crisbeto
5352
src/cdk/collections/** @jelbourn @crisbeto @andrewseguin
5453
src/cdk/a11y/** @jelbourn @devversion

CODING_STANDARDS.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,33 +127,20 @@ class ConfigBuilder {
127127
```
128128

129129
#### RxJS
130-
When dealing with RxJS operators, import the operator functions directly (e.g.
131-
`import "rxjs/operator/map"`), as opposed to using the "patch" imports which pollute the user's
132-
global Observable object (e.g. `import "rxjs/add/operator/map"`):
130+
When dealing with RxJS operators, import the lettable operator (e.g.
131+
`import {map} from 'rxjs/operators'`), as opposed to using the "patch" imports which pollute the
132+
user's global Observable object (e.g. `import 'rxjs/add/operator/map'`):
133133

134134
```ts
135135
// NO
136136
import 'rxjs/add/operator/map';
137137
someObservable.map(...).subscribe(...);
138138

139139
// YES
140-
import {map} from 'rxjs/operator/map';
141-
map.call(someObservable, ...).subscribe(...);
140+
import {map} from 'rxjs/operators';
141+
someObservable.pipe(map(...)).subscribe(...);
142142
```
143143

144-
Note that this approach can be inflexible when dealing with long chains of operators. You can use
145-
the `RxChain` class to help with it:
146-
147-
```ts
148-
// Before
149-
someObservable.filter(...).map(...).do(...);
150-
151-
// After
152-
RxChain.from(someObservable).call(filter, ...).call(map, ...).call(do, ...).subscribe(...);
153-
```
154-
Note that not all operators are available via the `RxChain`. If the operator that you need isn't
155-
declared, you can add it to `/core/rxjs/rx-operators.ts`.
156-
157144
#### Access modifiers
158145
* Omit the `public` keyword as it is the default behavior.
159146
* Use `private` when appropriate and possible, prefixing the name with an underscore.

package-lock.json

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@angular/http": "~4.4.3",
3434
"@angular/platform-browser": "~4.4.3",
3535
"core-js": "^2.4.1",
36-
"rxjs": "^5.0.1",
36+
"rxjs": "5.5.0-beta.0",
3737
"systemjs": "0.19.43",
3838
"tsickle": "^0.23.5",
3939
"tslib": "^1.7.1",

src/cdk/a11y/focus-monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
SkipSelf,
2121
} from '@angular/core';
2222
import {Observable} from 'rxjs/Observable';
23-
import {of as observableOf} from 'rxjs/observable/of';
23+
import {of as observableOf} from 'rxjs/Observable/of';
2424
import {Subject} from 'rxjs/Subject';
2525
import {Subscription} from 'rxjs/Subscription';
2626

src/cdk/a11y/focus-trap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/core';
1818
import {coerceBooleanProperty} from '@angular/cdk/coercion';
1919
import {Platform} from '@angular/cdk/platform';
20-
import {first} from '@angular/cdk/rxjs';
20+
import {first} from 'rxjs/operators';
2121
import {InteractivityChecker} from './interactivity-checker';
2222

2323

@@ -265,7 +265,7 @@ export class FocusTrap {
265265
if (this._ngZone.isStable) {
266266
fn();
267267
} else {
268-
first.call(this._ngZone.onStable.asObservable()).subscribe(fn);
268+
this._ngZone.onStable.asObservable().pipe(first()).subscribe(fn);
269269
}
270270
}
271271
}

src/cdk/a11y/list-key-manager.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {DOWN_ARROW, TAB, UP_ARROW} from '@angular/cdk/keycodes';
2-
import {first} from '@angular/cdk/rxjs';
2+
import {first} from 'rxjs/operators';
33
import {QueryList} from '@angular/core';
44
import {fakeAsync, tick} from '@angular/core/testing';
55
import {createKeyboardEvent} from '../testing/event-objects';
@@ -196,7 +196,7 @@ describe('Key managers', () => {
196196

197197
it('should emit tabOut when the tab key is pressed', () => {
198198
let spy = jasmine.createSpy('tabOut spy');
199-
first.call(keyManager.tabOut).subscribe(spy);
199+
keyManager.tabOut.pipe(first()).subscribe(spy);
200200
keyManager.onKeydown(fakeKeyEvents.tab);
201201

202202
expect(spy).toHaveBeenCalled();

src/cdk/a11y/list-key-manager.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {QueryList} from '@angular/core';
1010
import {Subject} from 'rxjs/Subject';
1111
import {Subscription} from 'rxjs/Subscription';
1212
import {UP_ARROW, DOWN_ARROW, TAB, A, Z, ZERO, NINE} from '@angular/cdk/keycodes';
13-
import {RxChain, debounceTime, filter, map, doOperator} from '@angular/cdk/rxjs';
13+
import {debounceTime, filter, map, tap} from 'rxjs/operators';
1414

1515
/**
1616
* This interface is for items that can be passed to a ListKeyManager.
@@ -65,23 +65,24 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
6565
// Debounce the presses of non-navigational keys, collect the ones that correspond to letters
6666
// and convert those letters back into a string. Afterwards find the first item that starts
6767
// with that string and select it.
68-
this._typeaheadSubscription = RxChain.from(this._letterKeyStream)
69-
.call(doOperator, keyCode => this._pressedLetters.push(keyCode))
70-
.call(debounceTime, debounceInterval)
71-
.call(filter, () => this._pressedLetters.length > 0)
72-
.call(map, () => this._pressedLetters.join(''))
73-
.subscribe(inputString => {
74-
const items = this._items.toArray();
75-
76-
for (let i = 0; i < items.length; i++) {
77-
if (items[i].getLabel!().toUpperCase().trim().indexOf(inputString) === 0) {
78-
this.setActiveItem(i);
79-
break;
80-
}
68+
this._typeaheadSubscription = this._letterKeyStream.pipe(
69+
tap(keyCode => this._pressedLetters.push(keyCode)),
70+
debounceTime(debounceInterval),
71+
filter(() => this._pressedLetters.length > 0),
72+
map(() => this._pressedLetters.join(''))
73+
)
74+
.subscribe(inputString => {
75+
const items = this._items.toArray();
76+
77+
for (let i = 0; i < items.length; i++) {
78+
if (items[i].getLabel!().toUpperCase().trim().indexOf(inputString) === 0) {
79+
this.setActiveItem(i);
80+
break;
8181
}
82+
}
8283

83-
this._pressedLetters = [];
84-
});
84+
this._pressedLetters = [];
85+
});
8586

8687
return this;
8788
}

src/cdk/observers/observe-content.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
NgZone,
2020
} from '@angular/core';
2121
import {Subject} from 'rxjs/Subject';
22-
import {RxChain, debounceTime} from '@angular/cdk/rxjs';
22+
import {debounceTime} from 'rxjs/operators';
2323

2424
/**
2525
* Factory that creates a new MutationObserver and allows us to stub it out in unit tests.
@@ -59,9 +59,8 @@ export class ObserveContent implements AfterContentInit, OnDestroy {
5959
ngAfterContentInit() {
6060
if (this.debounce > 0) {
6161
this._ngZone.runOutsideAngular(() => {
62-
RxChain.from(this._debouncer)
63-
.call(debounceTime, this.debounce)
64-
.subscribe((mutations: MutationRecord[]) => this.event.emit(mutations));
62+
this._debouncer.pipe(debounceTime(this.debounce))
63+
.subscribe((mutations: MutationRecord[]) => this.event.emit(mutations));
6564
});
6665
} else {
6766
this._debouncer.subscribe(mutations => this.event.emit(mutations));

src/cdk/rxjs/index.ts

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

src/cdk/rxjs/public_api.ts

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

src/cdk/rxjs/rx-chain.spec.ts

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

0 commit comments

Comments
 (0)