Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventStreamMarshaller

Utility class used to serialize and deserialize event streams in browsers and ReactNative. In browsers where ReadableStream API is available:

  • deserialize from ReadableStream to an async iterable of output structure
  • serialize from async iterable of input structure to ReadableStream In ReactNative where only async iterable API is available:
  • deserialize from async iterable of binaries to async iterable of output structure
  • serialize from async iterable of input structure to async iterable of binaries We use ReadableStream API in browsers because of the consistency with other streaming operations, where ReadableStream API is used to denote streaming data. Whereas in ReactNative, ReadableStream API is not available, we use async iterable for streaming data although it has lower throughput.

Hierarchy

Index

Constructors

Properties

Constructors

constructor

Properties

deserialize

  • deserialize<T>(body: Readable, deserializer: (input: {}) => Promise<T>): AsyncIterable<T>
  • deserialize<T>(body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, deserializer: (input: {}) => Promise<T>): AsyncIterable<T>
  • Type parameters

    • T

    Parameters

    • body: Readable
    • deserializer: (input: {}) => Promise<T>
        • (input: {}): Promise<T>
        • Parameters

          • input: {}

          Returns Promise<T>

    Returns AsyncIterable<T>

  • Type parameters

    • T

    Parameters

    • body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>
    • deserializer: (input: {}) => Promise<T>
        • (input: {}): Promise<T>
        • Parameters

          • input: {}

          Returns Promise<T>

    Returns AsyncIterable<T>

serialize

  • serialize<T>(input: AsyncIterable<T>, serializer: (event: T) => Message): Readable
  • serialize<T>(input: AsyncIterable<T>, serializer: (event: T) => Message): ReadableStream | AsyncIterable<Uint8Array>