RxJS - Utility Operator toArray
Accumulates all the source value from the Observable and outputs them as an array when the source completes.
Syntax
toArray():Observable
Return value
Returns an observable that outputs the values from the source observable as an array when the source completes.
Example
import { of} from 'rxjs';
import { toArray } from 'rxjs/operators';
let list1 = of(2, 3, 4, 5, 6);
let final_val = list1.pipe(toArray());
final_val.subscribe(x => console.log(x));
Output
[2, 3, 4, 5, 6]
Advertisements