Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DataHost<T>

A base class for a data host that is capable to store the data and provide it as a stream or a promise.

Type parameters

  • T

    Data type of the hosted data

Hierarchy

  • DataHost

Index

Constructors

constructor

  • new DataHost(infiniteResetHandler: (dataToReset: T, data: T[]) => T, streamOptions: StreamOptions): DataHost
  • Parameters

    • infiniteResetHandler: (dataToReset: T, data: T[]) => T
        • (dataToReset: T, data: T[]): T
        • Parameters

          • dataToReset: T
          • data: T[]

          Returns T

    • streamOptions: StreamOptions

    Returns DataHost

Methods

freeze

  • freeze(): void
  • Freeze the data host data. After freezing the data the data can be accessed by toStream and toPromise.

    Returns void

getPointCount

  • getPointCount(): number
  • Return how many points of data this data host has.

    Returns number

push

  • push(data: T[] | T): void
  • Push data to to the data host. Data is only accepted while the data host is not frozen.

    Parameters

    • data: T[] | T

      Data to add to the data host.

    Returns void

setData

  • setData(newData: T[]): void
  • Set the data to use as data source. Discards old data.

    Parameters

    • newData: T[]

      New data to use.

    Returns void

setStreamBatchSize

  • setStreamBatchSize(batchSize: number): DataHost<T>
  • Returns a new data host with the new batch size and same data that the original host had.

    Parameters

    • batchSize: number

      New batch size for the stream

    Returns DataHost<T>

setStreamInterval

  • setStreamInterval(interval: number): DataHost<T>
  • Returns a new data host with the new interval and same data that the original host had.

    Parameters

    • interval: number

      New interval delay for the stream

    Returns DataHost<T>

setStreamRepeat

  • Returns a new data host with the new repeat and same data that the original host had.

    Parameters

    Returns DataHost<T>

toPromise

  • toPromise(): Promise<T[]>
  • Returns the data as a promise. Consecutive calls always return a new instance of same data.

    Returns Promise<T[]>

toStream

  • Returns a new stream of the data that the host stores. Consecutive calls always return a new instance of same data.

    Returns Stream<T>