Skip to main content

fromReadableStream

Types

function fromReadableStream<GValue>(
readableStream: ReadableStream<GValue>,
): IObservable<IFromReadableStreamObservableNotifications<GValue>>

Definition

Creates an Observable from a ReadableStream. It emits values in the form of Notifications.

See fromReadableStreamReader for more details.

Example

Read data from a Response (Body)

async function run() {
const response = await fetch('https://somefile');
const subscribe = fromReadableStream(response.body);

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

run();

Output:

next: ArrayBuffer
next: ArrayBuffer
complete