Benjamin-Philip
Live Kino DataTable
I’ve got a GenServer with some tabular data that updates frequently. I would like to be able to render this live data. Presently, the way to go seems to create a smart cell for this, and write some custom JS to render my table. However, Kino.DataTable fits all my needs, and I just need a way of updating it. So, I would like to do this without replicating what’s already there in Kino.DataTable.
How do I render live data with a Kino.DataTable?
Most Liked
josevalim
Yes, allowing the data table to be updated would be great.
jonatanklosko
You can use Kino.Frame and render new Kino.DataTable into the frame as needed.
jonatanklosko
Oh, I assumed you don’t need to re-render so often. The slow re-render is less about Kino.Frame and more about Kino.DataTable, which is rendered inside an iframe (as are all Kino.JS), so it does need to load and run the JS again. If you want the table to quickly react to updates, then it should be a single Kino.JS.Live reacting to events.
We have a lower-level abstraction called Kino.Table, where you have more control over how you query the data, and you can enable a “Refetch” button to re-run the query. However, that’s still not reactive.
The current design of Kino.DataTable is very much static. To make it reactive we could add Kino.Table.update, which would invoke a new callback @callback update(update_arg) to update the state and then re-fetch and broadcast the current page. And then we could add Kino.DataTable.update(tabular) and implement the callback, which would be similar to the current Kino.Table.new and @callback init(init_arg).
cc @josevalim







