Reputation: 9
I want to connect ag-grid to lightstreamer as a socket. Does ag-grid support?
Upvotes: 0
Views: 198
Reputation: 2352
I've not used lightstreamer before, but based on their documentation it looks like it's a way of fetching data real time as a subscription.
I've implemented it here as a starting point that you can use, see the following plunkr
Note that all I've done here is added the logic from the npm page inside the Grid Event onGridReady:
onGridReady(params: GridReadyEvent) {
var sub = new Subscription(
'MERGE',
['item1', 'item2', 'item3'],
['stock_name', 'last_price']
);
sub.setDataAdapter('QUOTE_ADAPTER');
sub.setRequestedSnapshot('yes');
sub.addListener({
onItemUpdate: (obj) => {
const stockName = obj.getValue('stock_name');
const lastPrice = obj.getValue('last_price');
const newData = [
...this.rowData,
{ stock_name: stockName, last_price: lastPrice },
];
this.rowData = newData;
},
});
var client = new LightstreamerClient(
'http://push.lightstreamer.com',
'DEMO'
);
client.connect();
client.subscribe(sub);
}
Upvotes: 1