简体   繁体   中英

How to connect ag-grid (Live Streaming) to lightstreamer?

I want to connect ag-grid to lightstreamer as a socket. Does ag-grid support?

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);
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM