Skip to content

Commit 45abd01

Browse files
docs: update operator imports in content examples (#6739)
1 parent c0ed6c5 commit 45abd01

File tree

9 files changed

+141
-152
lines changed

9 files changed

+141
-152
lines changed

docs_app/content/deprecations/multicasting.md

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Instead of creating a [ConnectableObservable](/api/index/class/ConnectableObserv
3434

3535
<!-- prettier-ignore -->
3636
```ts
37-
import { ConnectableObservable, Subject, timer } from 'rxjs';
37+
import { ConnectableObservable, timer, Subject } from 'rxjs';
38+
3839
// deprecated
3940
const tick$ = new ConnectableObservable(
4041
timer(1_000),
@@ -44,7 +45,8 @@ tick$.connect();
4445

4546
<!-- prettier-ignore -->
4647
```ts
47-
import { connectable, Subject, timer } from 'rxjs';
48+
import { connectable, timer, Subject } from 'rxjs';
49+
4850
// suggested refactor
4951
const tick$ = connectable(timer(1_000), {
5052
connector: () => new Subject()
@@ -56,7 +58,8 @@ In situations in which the `refCount` method is used, the [share](/api/operators
5658

5759
<!-- prettier-ignore -->
5860
```ts
59-
import { ConnectableObservable, Subject, timer } from 'rxjs';
61+
import { ConnectableObservable, timer, Subject } from 'rxjs';
62+
6063
// deprecated
6164
const tick$ = new ConnectableObservable(
6265
timer(1_000),
@@ -66,8 +69,8 @@ const tick$ = new ConnectableObservable(
6669

6770
<!-- prettier-ignore -->
6871
```ts
69-
import { Subject, timer } from 'rxjs';
70-
import { share } from 'rxjs/operators';
72+
import { timer, share, Subject } from 'rxjs';
73+
7174
// suggested refactor
7275
const tick$ = timer(1_000).pipe(
7376
share({ connector: () => new Subject() })
@@ -80,8 +83,8 @@ Where [multicast](/api/operators/multicast) is called with a subject factory, ca
8083

8184
<!-- prettier-ignore -->
8285
```ts
83-
import { ConnectableObservable, timer, Subject } from 'rxjs';
84-
import { multicast } from 'rxjs/operators';
86+
import { timer, multicast, Subject, ConnectableObservable } from 'rxjs';
87+
8588
// deprecated
8689
const tick$ = timer(1_000).pipe(
8790
multicast(() => new Subject())
@@ -91,6 +94,7 @@ const tick$ = timer(1_000).pipe(
9194
<!-- prettier-ignore -->
9295
```ts
9396
import { connectable, timer, Subject } from 'rxjs';
97+
9498
// suggested refactor
9599
const tick$ = connectable(timer(1_000), {
96100
connector: () => new Subject()
@@ -101,8 +105,8 @@ Where [multicast](/api/operators/multicast) is called with a subject instance, i
101105

102106
<!-- prettier-ignore -->
103107
```ts
104-
import { ConnectableObservable, timer, Subject } from 'rxjs';
105-
import { multicast } from 'rxjs/operators';
108+
import { timer, multicast, Subject, ConnectableObservable } from 'rxjs';
109+
106110
// deprecated
107111
const tick$ = timer(1_000).pipe(
108112
multicast(new Subject())
@@ -112,6 +116,7 @@ const tick$ = timer(1_000).pipe(
112116
<!-- prettier-ignore -->
113117
```ts
114118
import { connectable, timer, Subject } from 'rxjs';
119+
115120
// suggested refactor
116121
const tick$ = connectable(timer(1_000), {
117122
connector: () => new Subject(),
@@ -123,8 +128,8 @@ Where [multicast](/api/operators/multicast) is used in conjunction with [refCoun
123128

124129
<!-- prettier-ignore -->
125130
```ts
126-
import { timer, Subject } from 'rxjs';
127-
import { multicast, refCount } from 'rxjs/operators';
131+
import { timer, multicast, Subject, refCount } from 'rxjs';
132+
128133
// deprecated
129134
const tick$ = timer(1_000).pipe(
130135
multicast(() => new Subject()),
@@ -134,8 +139,8 @@ const tick$ = timer(1_000).pipe(
134139

135140
<!-- prettier-ignore -->
136141
```ts
137-
import { timer, Subject } from 'rxjs';
138-
import { share } from 'rxjs/operators';
142+
import { timer, share, Subject } from 'rxjs';
143+
139144
// suggested refactor
140145
const tick$ = timer(1_000).pipe(
141146
share({ connector: () => new Subject() })
@@ -146,8 +151,8 @@ Where [multicast](/api/operators/multicast) is used with a selector, it can be r
146151

147152
<!-- prettier-ignore -->
148153
```ts
149-
import { timer, combineLatest } from 'rxjs';
150-
import { multicast } from 'rxjs/operators';
154+
import { timer, multicast, Subject, combineLatest } from 'rxjs';
155+
151156
// deprecated
152157
const tick$ = timer(1_000).pipe(
153158
multicast(
@@ -159,8 +164,8 @@ const tick$ = timer(1_000).pipe(
159164

160165
<!-- prettier-ignore -->
161166
```ts
162-
import { timer, combineLatest } from 'rxjs';
163-
import { connect } from 'rxjs/operators';
167+
import { timer, connect, combineLatest, Subject } from 'rxjs';
168+
164169
// suggested refactor
165170
const tick$ = timer(1_000).pipe(
166171
connect((source) => combineLatest([source, source]), {
@@ -175,8 +180,8 @@ If you're using [publish](/api/operators/publish) to create a [ConnectableObserv
175180

176181
<!-- prettier-ignore -->
177182
```ts
178-
import { ConnectableObservable, timer } from 'rxjs';
179-
import { publish } from 'rxjs/operators';
183+
import { timer, publish, ConnectableObservable } from 'rxjs';
184+
180185
// deprecated
181186
const tick$ = timer(1_000).pipe(
182187
publish()
@@ -185,7 +190,8 @@ const tick$ = timer(1_000).pipe(
185190

186191
<!-- prettier-ignore -->
187192
```ts
188-
import { connectable, timer } from 'rxjs';
193+
import { connectable, timer, Subject } from 'rxjs';
194+
189195
// suggested refactor
190196
const tick$ = connectable(timer(1_000), {
191197
connector: () => new Subject<number>(),
@@ -197,8 +203,8 @@ And if [refCount](/api/operators/refCount) is being applied to the result of [pu
197203

198204
<!-- prettier-ignore -->
199205
```ts
200-
import { timer } from 'rxjs';
201-
import { publish, refCount } from 'rxjs/operators';
206+
import { timer, publish, refCount } from 'rxjs';
207+
202208
// deprecated
203209
const tick$ = timer(1_000).pipe(
204210
publish(),
@@ -208,14 +214,14 @@ const tick$ = timer(1_000).pipe(
208214

209215
<!-- prettier-ignore -->
210216
```ts
211-
import { timer } from 'rxjs';
212-
import { share } from 'rxjs/operators';
217+
import { timer, share } from 'rxjs';
218+
213219
// suggested refactor
214220
const tick$ = timer(1_000).pipe(
215221
share({
216222
resetOnError: false,
217223
resetOnComplete: false,
218-
resetOnRefCountZero: false,
224+
resetOnRefCountZero: false
219225
})
220226
);
221227
```
@@ -224,8 +230,8 @@ If [publish](/api/operators/publish) is being called with a selector, you can us
224230

225231
<!-- prettier-ignore -->
226232
```ts
227-
import { timer, combineLatest } from 'rxjs';
228-
import { publish } from 'rxjs/operators';
233+
import { timer, publish, combineLatest } from 'rxjs';
234+
229235
// deprecated
230236
const tick$ = timer(1_000).pipe(
231237
publish((source) => combineLatest([source, source]))
@@ -234,8 +240,8 @@ const tick$ = timer(1_000).pipe(
234240

235241
<!-- prettier-ignore -->
236242
```ts
237-
import { timer, combineLatest } from 'rxjs';
238-
import { connect } from 'rxjs/operators';
243+
import { timer, connect, combineLatest } from 'rxjs';
244+
239245
// suggested refactor
240246
const tick$ = timer(1_000).pipe(
241247
connect((source) => combineLatest([source, source]))
@@ -248,8 +254,8 @@ If you're using [publishBehavior](/api/operators/publishBehavior) to create a [C
248254

249255
<!-- prettier-ignore -->
250256
```ts
251-
import { ConnectableObservable, timer } from 'rxjs';
252-
import { publishBehavior } from 'rxjs/operators';
257+
import { timer, publishBehavior, ConnectableObservable } from 'rxjs';
258+
253259
// deprecated
254260
const tick$ = timer(1_000).pipe(
255261
publishBehavior(0)
@@ -259,6 +265,7 @@ const tick$ = timer(1_000).pipe(
259265
<!-- prettier-ignore -->
260266
```ts
261267
import { connectable, timer, BehaviorSubject } from 'rxjs';
268+
262269
// suggested refactor
263270
const tick$ = connectable(timer(1_000), {
264271
connector: () => new BehaviorSubject(0),
@@ -270,8 +277,8 @@ And if [refCount](/api/operators/refCount) is being applied to the result of [pu
270277

271278
<!-- prettier-ignore -->
272279
```ts
273-
import { timer } from 'rxjs';
274-
import { publishBehavior, refCount } from 'rxjs/operators';
280+
import { timer, publishBehavior, refCount } from 'rxjs';
281+
275282
// deprecated
276283
const tick$ = timer(1_000).pipe(
277284
publishBehavior(0),
@@ -281,15 +288,15 @@ const tick$ = timer(1_000).pipe(
281288

282289
<!-- prettier-ignore -->
283290
```ts
284-
import { timer, BehaviorSubject } from 'rxjs';
285-
import { share } from 'rxjs/operators';
291+
import { timer, share, BehaviorSubject } from 'rxjs';
292+
286293
// suggested refactor
287294
const tick$ = timer(1_000).pipe(
288295
share({
289296
connector: () => new BehaviorSubject(0),
290297
resetOnError: false,
291298
resetOnComplete: false,
292-
resetOnRefCountZero: false,
299+
resetOnRefCountZero: false
293300
})
294301
);
295302
```
@@ -300,8 +307,8 @@ If you're using [publishLast](/api/operators/publishLast) to create a [Connectab
300307

301308
<!-- prettier-ignore -->
302309
```ts
303-
import { ConnectableObservable, timer } from 'rxjs';
304-
import { publishLast } from 'rxjs/operators';
310+
import { timer, publishLast, ConnectableObservable } from 'rxjs';
311+
305312
// deprecated
306313
const tick$ = timer(1_000).pipe(
307314
publishLast()
@@ -311,6 +318,7 @@ const tick$ = timer(1_000).pipe(
311318
<!-- prettier-ignore -->
312319
```ts
313320
import { connectable, timer, AsyncSubject } from 'rxjs';
321+
314322
// suggested refactor
315323
const tick$ = connectable(timer(1_000), {
316324
connector: () => new AsyncSubject<number>(),
@@ -322,8 +330,8 @@ And if [refCount](/api/operators/refCount) is being applied to the result of [pu
322330

323331
<!-- prettier-ignore -->
324332
```ts
325-
import { timer } from 'rxjs';
326-
import { publishLast, refCount } from 'rxjs/operators';
333+
import { timer, publishLast, refCount } from 'rxjs';
334+
327335
// deprecated
328336
const tick$ = timer(1_000).pipe(
329337
publishLast(),
@@ -333,15 +341,15 @@ const tick$ = timer(1_000).pipe(
333341

334342
<!-- prettier-ignore -->
335343
```ts
336-
import { timer, AsyncSubject } from 'rxjs';
337-
import { share } from 'rxjs/operators';
344+
import { timer, share, AsyncSubject } from 'rxjs';
345+
338346
// suggested refactor
339347
const tick$ = timer(1_000).pipe(
340348
share({
341349
connector: () => new AsyncSubject(),
342350
resetOnError: false,
343351
resetOnComplete: false,
344-
resetOnRefCountZero: false,
352+
resetOnRefCountZero: false
345353
})
346354
);
347355
```
@@ -352,8 +360,8 @@ If you're using [publishReplay](/api/operators/publishReplay) to create a [Conne
352360

353361
<!-- prettier-ignore -->
354362
```ts
355-
import { ConnectableObservable, timer } from 'rxjs';
356-
import { publishReplay } from 'rxjs/operators';
363+
import { timer, publishReplay, ConnectableObservable } from 'rxjs';
364+
357365
// deprecated
358366
const tick$ = timer(1_000).pipe(
359367
publishReplay(1)
@@ -363,6 +371,7 @@ const tick$ = timer(1_000).pipe(
363371
<!-- prettier-ignore -->
364372
```ts
365373
import { connectable, timer, ReplaySubject } from 'rxjs';
374+
366375
// suggested refactor
367376
const tick$ = connectable(timer(1_000), {
368377
connector: () => new ReplaySubject<number>(1),
@@ -374,8 +383,8 @@ And if [refCount](/api/operators/refCount) is being applied to the result of [pu
374383

375384
<!-- prettier-ignore -->
376385
```ts
377-
import { timer } from 'rxjs';
378-
import { publishReplay, refCount } from 'rxjs/operators';
386+
import { timer, publishReplay, refCount } from 'rxjs';
387+
379388
// deprecated
380389
const tick$ = timer(1_000).pipe(
381390
publishReplay(1),
@@ -385,15 +394,15 @@ const tick$ = timer(1_000).pipe(
385394

386395
<!-- prettier-ignore -->
387396
```ts
388-
import { timer, ReplaySubject } from 'rxjs';
389-
import { share } from 'rxjs/operators';
397+
import { timer, share, ReplaySubject } from 'rxjs';
398+
390399
// suggested refactor
391400
const tick$ = timer(1_000).pipe(
392401
share({
393402
connector: () => new ReplaySubject(1),
394403
resetOnError: false,
395404
resetOnComplete: false,
396-
resetOnRefCountZero: false,
405+
resetOnRefCountZero: false
397406
})
398407
);
399408
```
@@ -402,8 +411,8 @@ If [publishReplay](/api/operators/publishReplay) is being called with a selector
402411

403412
<!-- prettier-ignore -->
404413
```ts
405-
import { timer, combineLatest } from 'rxjs';
406-
import { publishReplay } from 'rxjs/operators';
414+
import { timer, publishReplay, combineLatest } from 'rxjs';
415+
407416
// deprecated
408417
const tick$ = timer(1_000).pipe(
409418
publishReplay(1, undefined, (source) => combineLatest([source, source]))
@@ -412,8 +421,8 @@ const tick$ = timer(1_000).pipe(
412421

413422
<!-- prettier-ignore -->
414423
```ts
415-
import { timer, combineLatest, ReplaySubject } from 'rxjs';
416-
import { connect } from 'rxjs/operators';
424+
import { timer, connect, combineLatest, ReplaySubject } from 'rxjs';
425+
417426
// suggested refactor
418427
const tick$ = timer(1_000).pipe(
419428
connect((source) => combineLatest([source, source]), {

docs_app/content/deprecations/resultSelector.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,16 @@ There were two reasons for actually deprecating those parameters:
2828

2929
Instead of using the `resultSelector` Argument, you can leverage the [`map`](/api/operators/map) operator on the inner Observable:
3030

31+
<!-- prettier-ignore -->
3132
```ts
32-
33-
import {fromEvent, interval} from 'rxjs';
34-
import {switchMap, map} from 'rxjs/operators';
33+
import { fromEvent, switchMap, interval, map } from 'rxjs';
3534

3635
// deprecated
3736
fromEvent(document, 'click').pipe(
38-
switchMap(x => interval(0, 1000), (x) => x+1)
37+
switchMap((x) => interval(1000), (_, x) => x + 1)
3938
);
4039
// suggested change
4140
fromEvent(document, 'click').pipe(
42-
switchMap(x => interval(0, 1000).pipe(
43-
map(x => x+1)
44-
))
41+
switchMap((x) => interval(1000).pipe(map((x) => x + 1)))
4542
);
4643
```
47-
48-
49-
50-
51-

0 commit comments

Comments
 (0)