web-serial-rxjs API Documentation
    Preparing search index...

    Function observableToWritable

    • Convert an RxJS Observable to a WritableStream.

      This utility function converts an RxJS Observable into a Web Streams API WritableStream. Values emitted by the Observable will be written to the returned WritableStream. The stream will close when the Observable completes or abort if the Observable errors.

      Note: This function creates a new WritableStream. For directly subscribing to an Observable and writing to an existing WritableStream, use subscribeToWritable instead.

      Parameters

      • observable: Observable<Uint8Array<ArrayBufferLike>>

        The Observable to convert to a WritableStream

      Returns WritableStream<Uint8Array<ArrayBufferLike>>

      A WritableStream that writes Uint8Array chunks emitted by the Observable

      const data$ = from([
      new TextEncoder().encode('Hello'),
      new TextEncoder().encode('World'),
      ]);

      const writableStream = observableToWritable(data$);
      // Use the writable stream with other Web Streams APIs