Refinitiv Data Library for TypeScript

Chain.StreamingChain

Summary

Extends EventEmitter.

Properties

name: string

Returned value: a chain record name.


isChain: boolean

Returned value: true if decoding is completed, otherwise false


Returned value: a list of the summary links of the chain record


state: State

Returned value: current state of the Pricing.Stream:

  • State.Opened
  • State.Pending
  • State.Closed

Methods

open()

Description: open the Chain connection


close()

Description: closes the Pricing connection, releases resources.

Returned value: Promise<void>.


getConstituents()

Returned value: a list of constituents in the chain record

There are several additional methods to subscribe to Pricing.Chain.Event
They all are aliases for the .on() method of the EventEmitter interfaces.

  • onAdd(cb: OnAddCallback): Chain.StreamingChain

  • onRemove(cb: OnRemoveCallback): Chain.StreamingChain

  • onComplete(cb: OnCompleteCallback): Chain.StreamingChain

  • onUpdate(cb: OnUpdateCallback): Chain.StreamingChain

  • onError(cb: OnErrorCallback): Chain.StreamingChain

Returned value: All of them return current instance of the Chain.StreamingChain, so you can chain them.

Example of usage

name example

console.log(chainStream.name);

isChain example

console.log(chainStream.isChain);
console.log(chainStream.summaryLinks);

getStream example

const streamChain = await chainDefinition.getStream(session);

await streamChain.open();

events examples

const streamChain = await chainDefinition.getStream(session)
    .onAdd((constituent: string, index: number, sc: Chain.StreamingChain): void => console.log(`${index}:${constituent}`)) // when the new element is added to constituents list

    .onRemove((constituent: string, index: number, sc: Chain.StreamingChain) => console.log(`${index}:${constituent}`))

    .onUpdate((newConstituent: string, oldConstituent: string, index: number, sc: Chain.StreamingChain) => console.log(`${index}:${oldConstituent}:${newConstituent}`))

    .onComplete((constituents: string[], sc: Chain.StreamingChain) => console.log(constituents)) // when chain decoding is completed, all constituents are passed as param

    .onError((err: Error, sc: Chain.StreamingChain) => console.log('error', err))
    .open();