Skip to content

Instantly share code, notes, and snippets.

View Diwakar14's full-sized avatar
๐Ÿ˜Ž
Learn => Implement

Diwakar Prasad Diwakar14

๐Ÿ˜Ž
Learn => Implement
View GitHub Profile
@markotny
markotny / fromFetchStream.ts
Last active October 26, 2023 18:05
Fetch streaming to rxjs (e.g. .NET IAsyncEnumerable)
import {Observable} from 'rxjs';
/**
* Stream server data (e.g. from endpoint returning IAsyncEnumerable)
* @type T type of stream element
* @param input input param of {@link fetch}
* @param init init param of {@link fetch} (excluding abort signal)
* @return stream of array elements one by one
*/
export function fromFetchStream<T>(input: RequestInfo, init?: RequestInit): Observable<T> {