thekangaroofactory / kitems

A framework to manage data frame items
https://thekangaroofactory.github.io/kitems/
GNU General Public License v3.0
0 stars 0 forks source link

[items] Check how to avoid filtered items to be initialized with all items #357

Open thekangaroofactory opened 1 month ago

thekangaroofactory commented 1 month ago

From testing, it seems that filtered_items is initialized with all items before being filtered. This makes plots be rendered twice upon startup. First with all data, then refreshed with filtered data.

Maybe date_slider get the whole range before the strategy (this-year) is applied. That could be a setting to make sure initialization is done properly and avoid unnecessary updates.

thekangaroofactory commented 1 month ago

filtered_items reactive calls:

  1. at init: filter_date is NULL so it returns the items
  2. when filter_date is updated: it returns the filtered items

If the first call is removed (bindEvent with ignoreInit = TRUE), then filtered_items will be NULL at startup But if the date slider is not used in the UI, it will always remain NULL

I didn't find any way to check that the date_slider will be in use (it's not initialized on first call, so the input does not exist)

This improvement requires to know if the user will implement the date slider in its UI. Maybe the date slider could be an option in the admin console Then we could skip first call with all items by returning NULL if the option is ON.

In the meantime, it's up to the user to set ignoreInit = TRUE when taking dependency on filtered_items if the date slider is implemented. For example, to not compute a plot on filtered_items until its updated. Documentation is delivered here #364

maybe check for the id in the ui html ??