BACK
Reference · 02

from

Turns an array, Promise, or iterable into an Observable.

Signature

from(input: ObservableInput): Observable

Marble diagram

from([a, b, c]):  (a b c |)

What it does

Accepts any ObservableInput — an array, Promise, iterable, async iterable, even another Observable — and wraps it in an Observable. For an array/iterable it emits each element in turn and completes. For a Promise it emits the result and completes (or errors).

When to use

The crossing point from the "imperative" world into the reactive one. Good for: an already-available data collection, a fetch()/HTTP Promise, generator iterators, Set/Map. With a Promise it replaces the deprecated fromPromise.

See also

of, fromEvent, defer

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