BACK
ReferencetoArray
Reference · 115

toArray

Collects all values into an array and emits it on complete.

Signature

toArray(): OperatorFunction

What it does

Buffers the whole stream until it completes. After complete, it sends one array with all the values.

When to use

Turning a finite Observable list into an array, grouping results, testing a sequence.

Gotcha

On an infinite stream, toArray never emits and holds onto memory.

See also

reduce, bufferCount

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...