How to use Grid.js with data being updated every second

Viewed 525
setInterval(() => {
  // lets update the config
  grid.updateConfig({
    server: {
      url: document.location.href + 'api.json/',
      then: data => data.map(obj => {
        return [obj.name, obj.value]
      }),
      handle: (res) => {
        // no matching records found
        if (res.status === 404) return { data: [] }
        if (res.ok) return res.json()
        throw Error('oh no :(')
      }
    }
  }).forceRender()
}, 2000)

This snippet make the work, but loading message and flicking/redraw all table are ruining UX.

0 Answers
Related