Reference · 01
of
of
Creates an Observable from the given values, then completes.
Signature
of(...values: T[]): Observable
Marble diagram
of(1, 2, 3): (1 2 3 |)
What it does
Emits each argument in turn synchronously, then sends complete. The subscription runs instantly — no async delays. Each argument passes through the stream exactly once; nothing is grouped or further unwrapped.
When to use
When you need an "instant" stream from a fixed set of values: mocks in tests, default values for combineLatest/startWith, or a short wrapper stream around a value you already have synchronously. Also handy for writing examples and teaching.
Gotcha
of([1, 2, 3]) is a stream of one array, not three values. To unpack the array into three emissions, use from([1, 2, 3]).
See also
from, scheduled, EMPTY
script.ts
CONSOLE · Console output
Hit Run to see the result...