我想将 ag-grid 作为套接字连接到 lightstreamer。ag-grid 支持吗?
问问题
35 次
1 回答
1
我以前没有使用过 lightstreamer,但根据他们的文档,它看起来像是一种实时获取数据作为订阅的方式。
我在这里实现了它作为您可以使用的起点,请参阅以下 plunkr
请注意,我在这里所做的只是在 Grid 事件 onGridReady中添加了来自npm 页面的逻辑:
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);
}
于 2022-02-21T15:37:32.437 回答