- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
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