Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
932 bytes
|
Line | |
---|
1 | import { OperatorFunction } from '../types';
|
---|
2 | /**
|
---|
3 | * Collects all source emissions and emits them as an array when the source completes.
|
---|
4 | *
|
---|
5 | * <span class="informal">Get all values inside an array when the source completes</span>
|
---|
6 | *
|
---|
7 | * ![](toArray.png)
|
---|
8 | *
|
---|
9 | * `toArray` will wait until the source Observable completes before emitting
|
---|
10 | * the array containing all emissions. When the source Observable errors no
|
---|
11 | * array will be emitted.
|
---|
12 | *
|
---|
13 | * ## Example
|
---|
14 | * ```ts
|
---|
15 | * import { interval } from 'rxjs';
|
---|
16 | * import { toArray, take } from 'rxjs/operators';
|
---|
17 | *
|
---|
18 | * const source = interval(1000);
|
---|
19 | * const example = source.pipe(
|
---|
20 | * take(10),
|
---|
21 | * toArray()
|
---|
22 | * );
|
---|
23 | *
|
---|
24 | * const subscribe = example.subscribe(val => console.log(val));
|
---|
25 | *
|
---|
26 | * // output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
---|
27 | *
|
---|
28 | * ```
|
---|
29 | * @return An array from an observable sequence.
|
---|
30 | * @method toArray
|
---|
31 | * @owner Observable
|
---|
32 | */
|
---|
33 | export declare function toArray<T>(): OperatorFunction<T, T[]>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.