Skip to main content

fromArrayWithNotifications

Alternative: fromArrayN

Types

function fromArrayWithNotifications<GValue>(
array: ArrayLike<GValue>,
): IObservable<IFromArrayObservableNotifications<GValue>>
type IFromArrayObservableNotifications<GValue> =
INextNotification<GValue>
| ICompleteNotification

Definition

Creates an Observable from an Array. It emits the array's values one by one in the form of next Notifications and then complete (complete Notification).

Diagram

OUTfromArrayWithNotifications([0, 1, 2, 3])OUTfromArrayWithNotifications([0, 1, 2, 3])next: 0next: 1next: 2next:3complete

Example

Emit the values 0, 1, 2, 3

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

subscribe((notification) => {
console.log(notification.name, ':', notification.value);
});

Output:

next: 0
next: 1
next: 2
next: 3
complete