LSEG Data Library for TypeScript

Delivery.OMMStream.Event

OMMStream.Event provides a set of events described below that can be emitted by the OMMStream.

OMMStream.Event.Refresh

Refresh events are emitted when all fields of the requested instrument are received. This complete list of fields is sometimes called the 'image' of the instrument.
This image that comes with Refresh messages can be later updated by subsequent Update events. When several Refresh events are received for the same instrument, the fields transported by the latest Refresh are considered as the new image. Fields received in previous Refresh events or Update events must be discarded.

OMMStreamRefreshCb callback parameters

Value Description Data type Optional Default value
data The new fields and values of the Image. object - -
stream The OmmStream object that emitted the event (see OMMStream). object - -

OMMStream.Event.Update

Update events are emitted when fields of the requested instrument change. Update events only contain the fields and values that have changed. When the application receives an Update it must update its internal representation of the instrument (if any) accordingly.

OMMStreamUpdateCb callback parameters

Value Description Data type Optional Default value
data The updated fields with their new values. object - -
stream The OMMStream object that emitted the event (see OMMStream). object - -

OMMStream.Event.Status

Status events are emitted when the status of one of the requested instruments changes.

OMMStreamStatusCb callback parameters

Value Description Data type Optional Default value
data The new status of the instrument. object - -
stream The OmmStream object that emitted the event (see OMMStream). object - -

OMMStatusResponse callback parameters

OMMStream.Event.Complete

A Complete event is emitted once the requested instrument received either a Refresh or a Status event. The Complete event indicates that the Pricing.Stream object is Complete and that it's internal cache contains the full data set (instruments and fields) that were requested.

OMMStreamCompleteCb callback parameters

Value Description Data type Optional Default value
stream The OmmStream object that is complete (see OMMStream). object - -

OMMStream.Event.Error

An Error event is emitted when an error message is received for the requested instrument.

OMMStreamErrorCb callback Parameters

Value Description Data type Optional Default value
error Error object received from the stream. Error No -
stream The OmmStream object that emitted the event (see OMMStream). object - -

Usage

The following example demonstrates how to attach event listeners on an OMM stream object.

import { Delivery } from '@lsegroup/data';

const stream = Delivery.OMMStream.Definition({
    name: 'EUR=',
    fields: ['DSPLY_NAME', 'PRCTCK_1']
}).getStream();

stream.on(OMMStream.Event.Refresh, (data) => console.log('Refresh event - Data:', data));
stream.on(OMMStream.Event.Update, (data) => console.log('Update event - Data:', data));
stream.on(OMMStream.Event.Status, (data) => console.log('Status event - Data:', data));
stream.on(OMMStream.Event.Complete, ommStream => console.log('Complete event'));
stream.on(OMMStream.Event.StateChanged, (ommStream, state) => console.log('OMMStream state changed:', state));
stream.on(OMMStream.Event.Error, (err) => console.log('Error event:', err));
`
369 words (1:57 mins)