( StackBlitz )
// RxJS v6+
import { interval } from 'rxjs';
import { toArray, take } from 'rxjs/operators';
interval(100)
.pipe(take(10), toArray())
.subscribe(console.log);
// output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- toArray 📰 - Official docs
📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/toArray.ts