Skip to main content

foundation-comms.getdatasource

Home > @genesislcap/foundation-comms > getDatasource

getDatasource() function

Get Datasource from the DI container.

Signature:

export declare function getDatasource(): Datasource;

Returns:

Datasource

Remarks

A utility method for host applications that are not using decorators or the DI container.

Example

import { FilteredDataServerResult, getDatasource, SocketObservable } from '@genesislcap/foundation-comms';
...
private ds = getDatasource();
private dsSub: SocketObservable<FilteredDataServerResult>;
...
const dsInit = await this.ds.init({
criteria: '',
isSnapshot: false,
resourceName: 'ALL_POSITIONS',
reverse: false,
maxRows: 250,
maxView: 1000,
});
if (!dsInit) {
logger.debug(`Failed to initialise 'ALL_POSITIONS' datasource`);
return;
}
this.dsSub = this.ds.stream.subscribe((result) => { ... });