Closed tzezar closed 2 weeks ago
I will rewrite the datagrid logic in my spare time to expose functions like sortData()
, filterData()
, paginateData()
on the datagrid instance which will be triggered by events like changing the filter etc. this will remove $effect() and hopefully, fix the duplicate logic application.
There is also the question of whether it would then be prudent to abandon the separation of these data states (filtered, sorted, paginated - data) in favor of one such as postProcessedData
paginatedData
, filteredData
, sortedData
no longer exist. Instead, use datagrid.state.processedData
.
Current behaviour:
Internal logic runs twice
Expected behaviour:
Internal logic runs once
Description:
In order to apply logic to the initial data as well as later update that data when filtering changes, using
$effect
we listen for changes todatagrid.state.filters
. For a reason unknown to me, svelte detects the change indata
on the first render even data stays the same.This results in whole chain of unnecessary logic applied to data, like pagination and sorting. It is very visible with huge datasets because sorting is expensive operation in some cases.
Potential solution:
Rewritingdoes not workfilterData
to retrieve the data directly from the context, which would eliminate passing data as props and probably fix this bugRewriting thedoes not workTzezarDatagrid
class to use$derrived
instead of$state
, which will remove the need to listen for changes with$effect