Closed abey79 closed 1 week ago
One solution is to simply add the full range as a second parameter to the closure:
let mut batch = vec![];
table_builder
.header(re_ui::DesignTokens::table_line_height(), header_ui)
.body(|body| {
body.rows(line_height, row_count, |row, row_range: Range<usize>| {
if row.index() == row_range.start {
batch = load_batch(row_range);
}
show(row, batch);
});
});
However, that's maybe not the most ergonomic.
An alternative is
table_builder
.header(re_ui::DesignTokens::table_line_height(), header_ui)
.body(|body| {
body.rows_ext(line_height, row_count,
|row_range: Range<usize>| load_batch(row_range),
|batch, row| show(row, batch)
);
});
Either would be fine for me. The former needs to guarantee that the closure is called in the correct order. The latter is slightly weird wrt to ownership (I assume body
take ownership of the first closure's returned value, and only provides a mutable(?) ref to the second closure)?
Wonder if a trait based API could be more ergonomics, as it could encompass everything (header row(s), on_row_batch()
, on_row()
, cell-based callback to accommodate for https://github.com/emilk/egui/issues/5001).
The current API is the following:
When displaying data that must be prefetched from some datastore with a paginated api(e.g. provide up to
limit
rows starting atoffset
), it would be useful to have an API that provide upfront the range of row indices that will be called.