Options
All
  • Public
  • Public/Protected
  • All
Menu

Stream

A Stream represents an ongoing stream of objects from a remote source, such as a MongoDB change stream as opened by a call to RemoteMongoCollection.watch.

Type parameters

  • T

    the type of the objects received by the stream.

Hierarchy

  • Stream

Index

Properties

Private Optional decoder

decoder: Decoder<T>

Private eventStream

eventStream: EventStream

Private listeners

listeners: Array<[StreamListener<T>, EventListener]>

Methods

addListener

  • Registers a StreamListener object whose onNext method will be called whenever this stream receives a new object, and whose onError method will be called whenever this stream produces an error. This listener can later be removed by removeListener.

    Parameters

    • listener: StreamListener<T>

      the listener object to be registered with this Stream

    Returns void

close

  • close(): void
  • Closes the underlying stream, which will prevent the stream from receiving any more events.

    Returns void

isOpen

  • isOpen(): boolean
  • Whether or not the underlying event stream is still open.

    Returns boolean

    true if open, false if no

next

  • next(): Promise<T>
  • Returns the next object received from the stream.

    Note

    This will not return any objects that were already received from the remote source but with no listener to process them. The object must be received from the remote source after this method is called.

    Returns Promise<T>

    a Promise containing the next object received from the stream. If there is no object yet available on the stream, the Promise will not resolve until there is.

onError

  • onError(callback: function): void
  • Sets up a callback that will be called when this stream produces an error. This callback cannot be cancelled.

    Parameters

    • callback: function

      a function that will be called whenever this stream produces an error.

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    Returns void

onNext

  • onNext(callback: function): void
  • Sets up a callback that will be called when objects are received from the stream. This callback cannot be cancelled.

    Parameters

    • callback: function

      a function that is to be called whenever objects are received by this stream.

        • (data: T): void
        • Parameters

          • data: T

          Returns void

    Returns void

removeListener

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc