Skip to main content

fromArray

Types

function fromArray<GValue>(
array: ArrayLike<GValue>,
): IObservable<GValue>

Definition

Creates an Observable from an Array. It emits the array's values one by one.

Diagram

Example

Emit the values 0, 1, 2, 3

const subscribe = fromArray([0, 1, 2, 3]);

subscribe((value: number) => {
console.log(value);
});

Output:

0
1
2
3